
C++ (C plusplus)
Requirements:
- Use the given class “User” (below)
- All data members must be declared as “private”
- No multiple return statements within a function or method
- No global variable is allowed to be declared and used (constants are ok)
- Methods within the class and the requested functions cannot have “cin” or “cout” but they should make use of parameters and return value instead unless it is explicitly stated.
- “cin” and “cout” should be used in main() and testing functions
- You are required to provide main() and testing functions if any that contains testing code to show how you have tested your classes, methods, and functions. You must show at least one call for each method and function and print out its return values and results correctly.
Define a new exception class named “BadValueException” that must inherit from the exception class. It will manage and capture the general invalid integer and double value. It must be able to describe the reason for the error and save away the erroneous value. In another word, when the caller catches the exception and receives this object, it must know what the reason for the exception is and the actual bad value that caused the exception.
Define a new class named “Student” that must inherit from the given User class. This class manages student info: id (integer), name (string), and gpa (double). It must prevent the creation of a Student object with a negative ID or a GPA that is not between the range of 0.0 and 4.0 by generating a BadValueException error.
This class will provide at least the following methods:
- toString method to return a string representation of the Student object in the format of “ID( <id> ) NAME( <name> ) GPA( <gpa> )” Such as:
ID(1234) NAME(John Smith) GPA(4.00)
Note: the GPA must have 2 decimal places.
- isGPAGreater method that compares its gpa with another student’s gpa. It returns true if its gpa is greater than the other and false otherwise.
Define another new class named “GradStudent” that must inherit from the Student class. This GradStudent class will manage the following info: id, name, gpa, and graduation year (integer). This class should allow the creation of a GradStudent object with or without a given graduation year. If the year is not given, it will default to 2022. Its toString() method should return a string with the graduation year info such as:
ID(3000) NAME(Nancy Brown) GPA(3.50) GRADUATION-YEAR(2022)
Write a function named “getLowest” that accepts a
For example, if these students and grad students are in the list:
Student(2000, "John Smith", 4.0)
GradStudent(3000,"Nancy Brown", 3.5, 2021) ;
Student(1000, "Bob Johnson", 3.0) ;
GradStudent(4000, "Tim Jackson", 2.0, 2020)) ;
It will return pointers to these two objects:
Lowest ID: ID(1000) NAME(Bob Johnson) GPA(3.00)
Lowest GPA: ID(4000) NAME(Tim Jackson) GPA(2.00) GRADUATIONYEAR(2020)
Write a function named “createOneStudent” that will read from the user the student info: id, name, and gpa. It will use try-catch to handle the exception if the user provides a negative id or gpa that is out of bound (< 0.0 or > 4.0) by asking the user to re-enter them. It must provide the correct reason for the error and the actual error value. Then it will allow the user to try up to 3 times. This function will return the pointer of a newly created Student object or nullptr if the info is still incorrect. Note that this function can and will use cin and cout to read in values from the user.
/////////////////////////////////////////
Given class “User”:
class User
{
private:
int m_id ;
string m_name ;
public:
User(int id, string name): m_id(id), m_name(name)
{
}
virtual string toString()
{
stringstream ss;
ss << "ID(" << m_id << ") NAME("<< m_name << ")" ;
return ss.str() ;
}
bool isIDLarger(User & another)
{
return m_id > another.m_id ;
}
};
Note: you cannot modify this given User class.
/////////////////////////////////////////
Expected result example (attached as a screenshot).


Trending nowThis is a popular solution!
Step by stepSolved in 5 steps with 1 images

- // CLASS PROVIDED: sequence (part of the namespace CS3358_FA2022)//// TYPEDEFS and MEMBER CONSTANTS for the sequence class:// typedef ____ value_type// sequence::value_type is the data type of the items in the sequence.// It may be any of the C++ built-in types (int, char, etc.), or a// class with a default constructor, an assignment operator, and a// copy constructor.//// typedef ____ size_type// sequence::size_type is the data type of any variable that keeps// track of how many items are in a sequence.//// static const size_type DEFAULT_CAPACITY = _____// sequence::DEFAULT_CAPACITY is the default initial capacity of a// sequence that is created by the default constructor.//// CONSTRUCTOR for the sequence class:// sequence(size_type initial_capacity = DEFAULT_CAPACITY)// Pre: initial_capacity > 0// Post: The sequence has been initialized as an empty sequence.// The insert/attach functions will work efficiently (without// allocating…arrow_forwardC++ Assignment---This is an unfinished code please complete it. Make changes if necessary. Upvote for finished working code. Objectives • To apply knowledge of classes and objects Instructions Implement all of the following, each in a separate Visual Studio project (and/or solution). 1. Define a class called CounterType to implement a simple counter. The class must have a private field (data member) counter of type int. You must also provide methods (member functions), including the following: a. A constructor to set the counter to the value specified by the user b. A constructor to set the counter to 0 c. A method to allow the user to set the counter to a value they specify d. A method to increment the counter by 1 e. A method to decrement the counter by 1 Your code must ensure the value of counter is never negative. If the user calls a method to attempt to make the counter negative, set the counter to 0 and print out an error to the user (e.g., “The counter must not be negative.”) Do…arrow_forwardC++ coding project just need some help getting the code thank you!arrow_forward
- In C++, all classes must be declared inside of the main function A) True B) Falsearrow_forwardfunctions return the value of a data member. A. Accessor OB. Member C. Mutator OD. Utilityarrow_forwardImportant requirements for all questions: • All data members must be declared as “private” • No global variable is allowed to be declared and used • Methods within the class and the requested functions cannot have “cin” or “cout” but it should make use of parameters and return value instead. • “cin” and “cout” should be done in main() or any testing functions • Make sure that you clearly show how the C++ class, its methods and all the functions are being called at least twice and print out its return value and its results properly.arrow_forward
- please assist me C++ language you are the owner of a pet store and you want to create a database of the different types of pets you sell you will create a base class called Pet and will include the following member variables: gender size (small, medium, or large) trained (yes or no) age long haired (yes or no) create two constructors default will initialize member variable with blanks or zeros second constructor will assign parameter values to each variable create your mutator functions create your accessor functions and save your Pet.h file create a new header file for dogs: dog.h it will be a derived class of Pet.h it will inherit the public functions of Pet.h it will have its own member variable breed (ie: beagle, collie, etc.) create the .cpp file, pet store create two instances of dog use the default constructor for the first dog use the second constructor for the second dog display both dog's data labeling each line report should look something like this…arrow_forward9.)arrow_forwardthis is ony one quiestion so please answer them all. USE C++arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





