Question

In: Computer Science

Create your own data type using a C++ structure. Assign values to a variable of that...

  • Create your own data type using a C++ structure.
  • Assign values to a variable of that data type.
  • Retrieve values from the variable of that data type.

Description:

In this lab you will choose the statements to create a program that:

Creates a brand new data type called "Monster". Once created, creates a variable of type Monster and assign values to the variable and then display the contents.

This lab will again take the form of a guided multiple-choice quiz like you had in the previous labs. For each question, pick the statement that implements the given requirement.

A Sample Run:

Monster name: Orc
Monster movement: 5
Monster dps: 3.5

Solutions

Expert Solution

//I have implemented the code you can take the input from the console and to run program use the // //below link from repl

//I have even used the strucure and used it as a data type

// LINK : https://repl.it/@FAYAZPASHA/OutstandingQuizzicalCarriers#main.cpp


#include<bits/stdc++.h>
using namespace std;

struct Monster{ //A User Defined Structure
   string name;
   int movement;
   float dps;
};

int main(){
   Monster monster;  //Using the predefined structure as a datatype

   //monster.name = "Orc";
   //monster.movement = 5;
   //monster.dps = 3.5;

   cout << "Enter Monster name: ";
   string name; cin >> name;

   cout << "Enter Monster Movements: ";
   int mov; cin >> mov;

   cout << "Enter Monster DPS: ";
   float dp; cin >> dp;

   monster.name = name;
   monster.movement = mov;
   monster.dps = dp;


   cout << "Monster name: " << monster.name << endl;
   cout << "Monster movement: " << monster.movement << endl;
   cout << "Monster dps: " << monster.dps << endl;

   return 0;
}


Related Solutions

Create a variable named specChars and assign it the values of all the punctuation items available...
Create a variable named specChars and assign it the values of all the punctuation items available on the top row of the keyboard, starting with the value above the number 1 through the value above the number 0. For example: !@#........ Prompt the user to enter a number between 1 and 10. For the number of times given by the user, randomly select one of the punctuation items in the specChars variable using the random.choice() function. Print the value that...
Write a c statement to declare variables of primitive data types, and assign values to the...
Write a c statement to declare variables of primitive data types, and assign values to the variables. Use common control structure in c, such as if, switch, break, for, while statements. Write a c program that takes command line parameters, and perform some computation based on the command line input. Write c statements to generate random number within a certain range. Write a c statement to declare array variables of primitive data types, and assign values to the elements of...
Using C#: Create a Form that consists of a PictureBox and 3 radio buttons. Assign an...
Using C#: Create a Form that consists of a PictureBox and 3 radio buttons. Assign an image of your choice to the PictureBox. Each radio button should be associated with a specific PictureBox size mode. When the user clicks on a specific radio button, the PictureBox's size mode should be changed to reflect the selection.
define "hypothesis" and create your own using variable weight and eating habits. Be sure to clarify...
define "hypothesis" and create your own using variable weight and eating habits. Be sure to clarify which variable is independent and which us dependent in your explenation
(C++ ONLY) You will define your own data type. It will be a struct called Fraction....
(C++ ONLY) You will define your own data type. It will be a struct called Fraction. The struct will have 2 integer fields: numerator and denominator. You will write a function called reduce that takes a Fraction as a parameter and returns that Fraction in its reduced form. For example, if the fraction 2/4 is passed to the function, the fraction 1/2 will be returned. Consider any fraction with a denominator of 1 to be in reduced form. You will...
In C, create a program that displays the minimum and maximum values stored in a data...
In C, create a program that displays the minimum and maximum values stored in a data file "datafile.txt". Use the following function prototype:  void minmaxarray(float value, float *min, float *max);
Create the appropriate variables and algorithm to calculate the following. Choose your own values for the...
Create the appropriate variables and algorithm to calculate the following. Choose your own values for the variables. Do not enter the code on this paper. Create a program that calculates and displays the calculation. Approximate pi (π) as 3.14159. You do not need to create a new program for each question. If certain math equations use the same variable name, then you only need to declare it once in your main function. Separate each problem using comments, like seen in...
write a Program in C++ Using a structure (struct) for a timeType, create a program to...
write a Program in C++ Using a structure (struct) for a timeType, create a program to read in 2 times into structures, and call the method addTime, in the format: t3 = addTime(t1, t2); Make sure to use add the code to reset and carry, when adding 2 times. Also, display the resultant time using a function: display(t3);
Unix Create a script that will declare an array and assign four values from the command...
Unix Create a script that will declare an array and assign four values from the command line. 1. Use these four values - Paul, Ringo, George, John, - in that order 2. Display the content of the array, displaying the values in this format and this order The first array value is "John" The second array value is "Paul" The third array value is "George" The fourth array value is "Ringo"
Data structure program Implement (your own) the Radix Sort using single linked list java language
Data structure program Implement (your own) the Radix Sort using single linked list java language
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT