Define an accessor method (also known as getter) and a mutator method (also known as setter) for each attribute of the class. For example, as for the attribute code, define two methods for it, i.e., getCode () and setCode (). Keep in mind that the accessors should be declared as constant methods. Define three more accessor methods below: a. a method that determines the grade earned for the subject based on the score. For example, if the score earned is 70, this method should return "B+". b. a method that determines the point value of the grade earned. For example, if the grade earned is "B+", this method should return 3.33.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
4. Define an accessor method (also known as getter) and a mutator method (also known as setter)
for each attribute of the class. For example, as for the attribute code, define two methods for it,
i.e., getCode () and setCode (). Keep in mind that the accessors should be declared as
constant methods.
5. Define three more accessor methods below:
a. a method that determines the grade earned for the subject based on the score. For example,
if the score earned is 70, this method should return "B+".
b. a method that determines the point value of the grade earned. For example, if the grade
earned is "B+", this method should return 3.33.
c. a method that determines the point earned for the subject. For example, if the subject is 3
credit hour and the grade point earned is 3.33, this method should return 9.99
See the section below for the formulas.
6. In the main function, write the code to accomplish the following requirements:
a. Instantiate or create an object from the class.
b. Read inputs from the user and use them to set the attributes of the object.
c. Print the subject information such as the code, name, score, grade, etc. See example runs
in the following figures for the expected results.
Transcribed Image Text:4. Define an accessor method (also known as getter) and a mutator method (also known as setter) for each attribute of the class. For example, as for the attribute code, define two methods for it, i.e., getCode () and setCode (). Keep in mind that the accessors should be declared as constant methods. 5. Define three more accessor methods below: a. a method that determines the grade earned for the subject based on the score. For example, if the score earned is 70, this method should return "B+". b. a method that determines the point value of the grade earned. For example, if the grade earned is "B+", this method should return 3.33. c. a method that determines the point earned for the subject. For example, if the subject is 3 credit hour and the grade point earned is 3.33, this method should return 9.99 See the section below for the formulas. 6. In the main function, write the code to accomplish the following requirements: a. Instantiate or create an object from the class. b. Read inputs from the user and use them to set the attributes of the object. c. Print the subject information such as the code, name, score, grade, etc. See example runs in the following figures for the expected results.
In this exercise, you will be writing a C++ program that displays the grade earned for given score of a
subject. You will be using an Object-Oriented Programming (OOP) approach to write the program.
Notes:
Write the program in a single source code file and use the inline style to define the class. That
means, the definition of each method is written directly in the class declaration.
• Follow proper naming convention:
o Use camel Case to name functions, methods, and variables.
▪ Example: int calculateTotal(), int thisIsVariable
O
Use Pascal Case to name class and data type.
Example: class Student { }
o Use CAPITAL case to all characters to name constants.
▪ Example: const int MAXIMUM_STUDENT = 10;
o Use small case to all characters to name a file
■ Example:
my_main_program.cpp
Modify the starter program provided (main.cpp) to accomplish the following tasks:
1. Declare a class to model subject information which consists of three attributes, the subject's name,
code, and the score earned for the subject. In your code, you should also implement the "data
hiding" principle for the class.
2. Define two constructors for the class as follows:
a. a parameterized constructor which accepts parameters to set the attributes.
b. a default constructor method which sets the attributes to "empty" values
3. Define the destructor method for the class which does nothing.
Transcribed Image Text:In this exercise, you will be writing a C++ program that displays the grade earned for given score of a subject. You will be using an Object-Oriented Programming (OOP) approach to write the program. Notes: Write the program in a single source code file and use the inline style to define the class. That means, the definition of each method is written directly in the class declaration. • Follow proper naming convention: o Use camel Case to name functions, methods, and variables. ▪ Example: int calculateTotal(), int thisIsVariable O Use Pascal Case to name class and data type. Example: class Student { } o Use CAPITAL case to all characters to name constants. ▪ Example: const int MAXIMUM_STUDENT = 10; o Use small case to all characters to name a file ■ Example: my_main_program.cpp Modify the starter program provided (main.cpp) to accomplish the following tasks: 1. Declare a class to model subject information which consists of three attributes, the subject's name, code, and the score earned for the subject. In your code, you should also implement the "data hiding" principle for the class. 2. Define two constructors for the class as follows: a. a parameterized constructor which accepts parameters to set the attributes. b. a default constructor method which sets the attributes to "empty" values 3. Define the destructor method for the class which does nothing.
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY