The objectives of the questions are to:
Examine the following class diagram, additional information and answer the questions that follow:
CarSpeed
acceleration: float
engine_number: string
start: bool
CarSpeed(float = 0, string = "", bool = false)
start_car():void
stop_car():void
set_acceleration(float): void
set_engine_number(string): void get_velocity(float): float
Additional Information:
(a)List FOUR (4) characteristics of a constructor
(b)Develop C++ code to implement the CarSpeed Class specification.
(c)Develop C+ code to implement ALL the methods found in the CarSpeed class.
(d)Inspect the sample output, as shown below and write a test driver to test and fulfil the following requirements:
Uses a loop that repeats 3 times to prompt the user to enter the engine number, acceleration and time and use the various mutators to set the engine number, acceleration & time. It further invokes the method to compute and display the respective velocities.. The velocity is displayed with 2 decimal places. See image.
The objectives of the question are to:
You are required to write the declaration and implementation code in separate files. Your submission is expected to reflect this.
Examine the following class specifications, additional information and answer the questions that follow:
class Date
{
int dd;
int mm;
int yy;
public:
Date(int = 1, int=1, int=2015);
void setDate(int, int, int);
int getDD();
int getMM();
int getYY();
};
class Appointment
{
private:
string NRIC;
string name;
double fees;
Date visit;
Date nextVisit;
public:
Appointment();
void setAppt(string, string, double, Date, Date);
Date getVisit();
Date getnextVisit();
string getName();
void displayAppt();
void displayAppt(string);
};
Additional Information:
Note1: When there is no next visit, the data members, dd, mm and yy in Date class are set to 0.
(a)Define method overloading. Identify the overloaded method(s) found in the given class(es).
(b)Develop C++ code to implement ALL the methods found in the above-mentioned class specifications:
(c)Write a test driver to test ALL the methods in the Date and Appointment classes. The test driver should include the following:
Include a screen output similar to the sample screen output shown below in your submission.
Test Data
NRIC Name Fees Date of Visit Date of next visit
S12345 Tan Ah Sam 45.00 2 March 2015 8 June 2015
S34567 Lee Tao San 60.00 3 March 2015 -
S56783 Sam Ting 120.50 10 March 2015 31 March 2015
S98761 Anthony Chin 78.50 31 March 2015 30 April 2015
Sample Screen Output See image.
The objectives of the question are to:
Examine the given class specification, data files, additional information and answer the questions that follows:
class Format
{
private:
int number;
public:
void writeFile();
};
Additional Information:
Input File(IN.dat)Output File (OUT.dat) See image.
(a)Define ifstream and ofstream.
(b)Using C++ code, develop the writeFile method, fulfilling the requirement stated in the Additional Information above.
(c)Write a test driver to test the following:
The objectives of the question are to:
Study the given class diagrams, additional information and answer questions that follow:
Pledge
amt1: float
Pledge();
Pledge(float = 1.00);
virtual add_pledge(float): void
virtual get_pledge():float;
virtual display():void
SpecialPledge
*amt2: float
SpecialPledge(float);
add_pledge(float): void
get_pledge():float
display():void
Additional Information:
(a)Using C++ code, construct the class specification for
(b)Write C++ code to implement the constructor and methods found in
(c)Write a test driver to fulfil the following requirements:
Sample Output
Test Display Method
Pledge Object:
========================
Pledged Amount $:200
Special Pledge Object:
========================
Pledged Amount for month 1 $:50
Pledged Amount for month 2 $:50
Pledged Amount for month 3 $:50
Pledged Amount for month 4 $:50
Pledged Amount for month 5 $:50
Pledged Amount for month 6 $:50
Pledged Amount for month 7 $:50
Pledged Amount for month 8 $:50
Pledged Amount for month 9 $:50
Pledged Amount for month 10 $:50
Pledged Amount for month 11 $:50
Pledged Amount for month 12 $:50
Test add_pledge Method
Enter the pledged amount for Pledge Object:
========================================================
23
Enter the pledged amount for Special Pledge Object:
========================================================
78
Enter the month: 9
Test get_pledge Method
Pledged Amount
==============
Total for Pledge Amount: 223
Total for Special Pledge Amount: 678
Test Display Method
Pledge Object:
===============
Pledged Amount $:223
Special Pledge Object:
===============
Pledged Amount for month 1 $:50
Pledged Amount for month 2 $:50
Pledged Amount for month 3 $:50
Pledged Amount for month 4 $:50
Pledged Amount for month 5 $:50
Pledged Amount for month 6 $:50
Pledged Amount for month 7 $:50
Pledged Amount for month 8 $:50
Pledged Amount for month 9 $:128
Pledged Amount for month 10 $:50
Pledged Amount for month 11 $:50
Pledged Amount for month 12 $:50
Press any key to continue . . .