Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3 . 1 0 ( Sct and Get Functions ) Explain why a class inighe provide a set function and a get function for a

3.10(Sct and Get Functions) Explain why a class inighe provide a set function and a get function for a data member.3.11(Modifying Class GradeBook) Modify class GradeBook (Pigs.3.11-3.12) as follows:a) Include a second string data member that represents the course instructor's name.b) Provide a set function to change the instructor's name and a get function to recrieve it.c) Modity the constructor to specify course nanic and instructor name parameters.d) Modify function displayMessage to output the welcome message and course name, then the string. "This course is presented by:" followed by the instructor's name.Use your modified class in a test program that demonstrates the class's new capabilities.3:12(Account Class) Create an Account class that a bank might use to represent customers bank accounts. Include a data member of type int to represent the account balance. [Note; In subsequent chapters, well use numbers that contain decimal points (eg.,2.75) called floating-point values to represent dollar amounts.] Provide a constructor that reccives an initial balance and uses it to initialize the data member. The consuructor should validate the inirial balance to ensure that it's greater than or equal to 0. If not, set the balance to 0 arid display an error message indicating that the initial balance was invalid. Provide three member functions. Member function credit should add an amount to the current balance. Member function debit should withdraw money from the Account and ensure chat the debit amount does not exceed the Account's balance. If it does, the balance should be left unchanged and the tunction should print a message indicating "Debit amount exceeded account balance." Member function getBalance should return the current balance. Create a program that creates rwo Account objeces and tests the member functions of class Account.3,13(Invoice Class) Create a class called Invotce that a hardhvare store might use to represent an invoice for an item sold at the store. An Invoice should include four data members-- a pat number (type string), a part description (type string), a quantity of the item being purchased (type int) and price per item (type int).(Nete: In subsequent chapters, we'll use numbers that contain decimal points (e.g.: 2.75)-called floating-point values to represent dollar amounts.) Your class should have a constructor that initializes the four data members. A constructor that receives multiplearguments is defined with the form:Class Name( TypeNamel parameter Namel, Spellamel parameter Namel;..)Provide a set and a get function. for each data member. In addition, provide a member function named getInvoiceAnount that calculates the invoice amount (Le, multiplies the quantity by the price per item, then returns the amount as an int value. If the quantity is not positive, it should be set to 0. If the price per item is not positive, it should be set to 0. Write a test program that demonstrates class Invoices capabilities.3.14(Esployee Class) Create a class called Employee that includes three pieces of information as dara members-a first name (type string), a last name (type string) and a monthly salary (typeint).[Note: In subsequent chapters, well use numbers that contain decimal points (eg,2.75)-called floating-point values -to represent dollar amounts.] Your class should have a constructor that initializes the three data members. Provide a set and a get function for each data member. If the monthly salary is not positive, set it to 0. Write a test program that demonstrates class Employee's capabilities: Create two Employee objeets and display each object's yearly salary. Then give each Employee a 10 percent raise and display each Employee'S yearly salary again.3.15(Date Class) Create a class called Date that includes three pieces of information as data membersa month (type int), a day (type int) and a year (cype int). Your class should have a con-structot with three parameters that uses the parameters to initialize the three data members. For the purpose of this exercise, assume that the values provided for the year and day are correct, but ensure that che month value is in the range 1-12, if it isn't, set the month to T. Provide a set and a ger func dion for each data member. Provide a member function displayDate that displays the month, day
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Performance Indexing In SQL Server

Authors: Jason Strate, Grant Fritchey

2nd Edition

1484211189, 9781484211182

More Books

Students also viewed these Databases questions