Indicate whether each of the following enumerated data type definitions is valid or invalid. If it is invalid, tell what is wrong with it.
A) enum Holiday { Easter, Halloween , Thanksgiving, Christmas};
B) Enum Holiday { Easter, Halloween, Thanksgiving, Christmas};
C) enum Holiday { "EASTER", "HALLOWEEN"",T HAKNSGIVING", "CHRISTMAS"} ;
D) enum Holiday { EASTER, HALLOWEEN, THANKSGIVINGC, HRISTMAS}
nextHoliday;
Want to see the full answer?
Check out a sample textbook solutionChapter 7 Solutions
Starting Out with C++: Early Objects (9th Edition)
Additional Engineering Textbook Solutions
Software Engineering (10th Edition)
Web Development and Design Foundations with HTML5 (8th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Starting Out with C++ from Control Structures to Objects (8th Edition)
Starting Out with Java: Early Objects (6th Edition)
- FOR C++, ACCORDING THE VEHICLE HEADER, FILL THE PART 1 OF THE CODE #ifndef _Vehicle_hh_ #define _Vehicle_hh_ class Vehicle { private: float speed; float mile; public: Vehicle(); Vehicle(float, float); float getSpeed(); float getMile(); void setSpeed(float); void setMile(float); void print(); }; #endif (DEFINE FUNCTIONS CORRESPONDING TO VEHICLE HEADER CLASS IN PART 1 BELOW) #include "Vehicle.hh" #include "Ship.hh" #include <iostream> using namespace std; // *** DEFINE --VEHICLE-- FUNCTIONS FOR PART 1 *** // *** DEFINE --SHIP-- FUNCTIONS FOR PART 2 *** void reduceSpeed(Ship*, float); void takePassenger(Ship*, int); int main() { return 0; } // reduce the speed of ship given in percentage (0 < percentage < 1). void reduceSpeed(Ship *s, float percentage) { // *** FILL THIS FUNCTION FOR PART 3 *** } // takes the number of passengers to the ship void takePassenger(Ship *s, int pas) { // *** FILL THIS FUNCTION FOR…arrow_forwardPlease answer in Programming C++ Define a structure called Class with name (string), units (int) and grade (char) as its member data. Define a structure called Student with ID (int), name (string), num (int), gpa (double) and an array of maximum of 20 Class structures called classes, where ID is a 5 digit number, name is the student's full name, num is the number of classes taken so far and gpa is the current grade point average and classes is all the classes taken so far. Write a function called get_info which takes an array of Student structures called students and array size, reads all the information for as many students as the user wants to enter except for the gpa which is later calculated, storing them in students array. It then returns the number of students entered by the user before quitting. The user indicates the end of data entry by entering -99 for the ID of a student. The user must enter as many classes for each student as indicated by num - number of classes. Write a…arrow_forward1) Convert your structure into a class. For this exercise, you can leave the data as public (otherwise you would have to change the input and output functions). 2) Write a member function show_all that prints all the information for one record - name, cost, markup, and the three inventory numbers. 3) Add a user option S that lets the user see all the information for all the items in the inventory, using the show_all member function. Print a header so the user knows what each column means, and format the output to appear in columns. Hint: do a setwidth() before *each* cout. Pick widths that make sense for name, cost, markup, and the three inventory numbers. Previous code: #include <iostream>#include <fstream>#include <vector>using namespace std; struct Record {string name;double cost;int markup;int count[3];}; const string places[3] = {"counter", "shelf", "warehouse"}; bool read_file(vector <Record> &v);void placement (vector <Record> &v);void…arrow_forward
- PROGRAMMING LANGUAGE: C++ Write a complete C++ program with the following features.a. Declare a class Time with two fields, hour and minute.b. Provide appropriate constructors to initialize the data members.c. Overload the pre and postfix increment operators (using memberfunctions) to increment the minutes by one. Also make sure if m inutes are59 and you increment the Time it should update hours and minutesaccordingly.d. Provide a function display() to display the hours and minutes.e. In main(), create objects of Time, initialize them using constructors andcall the display functions.f. Test the following in your main:a. T3= ++T1;b. T4=T2++;arrow_forwardProgramming Language: C++ Make a program wherein you have to create an Abstract Data Type, which will store 2 integer number. After that, make operations which will set the value of the two numbers, add, subtract, multiply and divide. After creating the abstract data type, use it in the main class. Ask the user for the value of two integers. Ask the user what operation to use, then call the necessary operation based on the user's input. Then display the answer with the correct label. Do not copy paste codes from other sites.arrow_forwardType conversion, type coercion, and nonconverting type casts should all be defined.arrow_forward
- Q No 3. #include <string> using namespace std; class Account { public: Account(string accountName, int initialBalance) { name=accountName; if (initialBalance > 0) { balance = initialBalance; } } void deposit(int depositAmount) { if (depositAmount > 0) { balance = balance + depositAmount; } } int getBalance() const { return balance; } void setName(string accountName) { name = accountName; } string getName() const { return name; } private: string name; int balance; }; Rewrite the following code in correct form. a) Assume the following prototype of destructor is declared in class Time: void ~Time(int); b) Assume the following prototype of constructor is declared in class Employee: int Employee(string, string);…arrow_forwardThis is an object oriented programming question The code should be in C++ language Create a class Student having a private data members S_ID, S_Name and S_CGPA. Now create a public member functions void getID(), void getName() and getCGPA() and finally to display all the data members, create a function void display(). In the main(), create an array of student class, size of the array should be taken from user at run time and call all the functions defined in the class. Sample Output: Student 1 Enter ID: 1 Enter Name: Ali Enter CGPA: 2.5 Student 2 Enter ID: 2 Enter Name: Ahmed Enter CGPA: 2.9 Student 3 Enter ID: 3 Enter Name: Zain Enter CGPA: 3.4 Student 1 informationID: 1 Name: Ali CGPA: 2.5 Student 2 information ID: 2 Name: Ahmed CGPA: 2.9 Student 3 information ID: 3 Name: Zain CGPA: 3.4arrow_forward) Define a struct type to represent a university student with a name, surname, course, year. 2) Define a couple of named instances, e.g., David, Pearl, Computing, Year1. 3) Apply selector function to return the course and year of your student.4) Write a function that updates the year of a student, i.e. if year is “Year1”, then update to “Year2”, if year is “Year2”, then update to “Year3”, if the year is “Year3” then updated to “Graduated”. Make sure to write what the difference between mutable and immutable is.arrow_forward
- Program in C: Part A: Write the code that defines a struct called dog The following information must be kept in appropriate data types: the name of the dog (char array) the breed of the dog (char array) the wieght of the dog (double) Part B: Write a function called GetDogInfo that declares a temporary dog and fills the 3 data fields with user input (remember to prompt for input) return the filled dog (the function return type is dog) Part C: Write a main function with a function call to GetDogInfoarrow_forwardUsing C++ Create a class named employee with name(type string) and points (type double). Include a two-argument constructor for initializing the name and points. create a static function named getBest that receive array of 5 objects and find and return the object with maximum points.arrow_forwardPlease answer in C++ / Text book question / C++ for scientist and Engineers 3rd edition Construct a class named Fractions containing two integer data members named num and denom, used to store the numerator and denominator of a fraction having the form num/denom. Your class should include a default constructor that initializes num and denom to 1 and four operator functions for adding, subtracting, multiplying, and dividing the two fractions, as follows: Addition: a/b + c/d = (a * d + b * c) / (b * d)Subtraction: a/b - c/d = (a * d - b * c) / (b * d)Multiplication: a/b * c/d = (a* c) / (b * d)Division: (a/b) / (c/d) = (a * d) / (b * c) Finally, your class should have a member function that reduces each fraction to its terms (refer to Exercise 15 in Programming Projects for Chapter 6 for how to do this) as well as input and output functions for entering and displaying a fraction. thanksarrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr