6 Lab Problems From C++ That I Need Help In ..any Coding Master ?!?

Lab 13: P6.13 on page 300
Exercise P6.13. Write a program that prints out a bank statement. The program input
is a sequence of transactions. Each transaction has the form
day amount description
For example,
15 -224 Check 2140
16 1200 ATM deposit
Your program should read in the descriptions and then print out a statement listing all deposits, withdrawals,
and the daily balance for each day.
You should then compute the interest earned by the account.Use both the minimum daily balance and
the average daily balance methods for computing interest, and print out both values. Use an interest rate
of 0.5 percent per month, and assume the month has 30 days.
You may assume that the input data are sorted by the date. You may also assume that the first entry is of the form
1 1143.24 Initial balance
– in main
cout: “initial balance” amount 1143.24
cout: “Transaction”
cout << "day";
cout << "———-";
cout << "amount";
cout << "———-";
cout << "description" ;
class bank
bank(int day, int amount, string description):
vector day;
vector amount;
vector description;
interest rate 0.5 percent per month: –> 0.5/30 = 0.01667
minimum daily balance:
average daily balance:
double average(vector values)
if (values.size() == 0) return 0;
double sum = 0;
for (int i = 0; i < values.size(); i++)
sum = sum + values[i];
return sum / values.size();
Lab 14: P6.16 on page 301
Exercise P6.16. The following table can be found in the “West Suburban Boston,
Area Code 617, 1990–1991” telephone book.
8 am – 5 pm : full rate
5 pm – 11 pm : 35% discount
11 pm – 8 am & weekend: 60% discount
Dial direct
Weekday—–full rate: .26 cent
Evening—-35% discount : .16 cent
Night & Weekend——60% discount : .10 cent
Write the a program that asks the user:
• the destination of the call
• the starting time
• the length of the call
• the weekday
The program should compute and display the charge. Note that the rate may vary.
If the call starts at 4:50 P.M. and ends at 5:10 P.M., then half of it falls into the day
rate and half of it into the evening rate.
Write a program that asks the user: The destination of the call; The starting time; The length of the call; The weekday
Lab 15: P7.2 on page 338
Exercise P7.2. Implement a class Person with two ?elds name and age, and a class Car
with three ?elds:
• the model
• a pointer to the owner (a Person*)
• a pointer to the driver (also a Person*)
Write a program that prompts the user to specify people and cars. Store them in a
vector and a vector. Traverse the vector of Person objects and incre-
ment their ages by one year. Finally, traverse the vector of cars and print out the car
model, owner’s name and age, and driver’s name and age.
Lab 16: P7.12 on page 339
Exercise P7.12. Add a member function
void Employee::format(char buffer[], int buffer_maxlength)
to the Employee class.
The member function should fill the buffer with the name and
salary of the employee. Be sure not to overrun the buffer. It can hold
buffer_maxlength characters, not counting the ” terminator. (That is, the buffer
has buffer_maxlength + 1 bytes available.) Be sure to provide a ” terminator.
Lab 17: P8.1 on page 372
Exercise P8.1. Derive a class Programmer from Employee. Supply a constructor
Programmer(string name, double salary) that calls the base-class constructor.
Supply a function get_name that returns the name in the format “Hacker, Harry
#ifndef EMPLOYEE_H_
#define EMPLOYEE_H_
using std::string;
class Employee {
Employee(string name, double salary);
virtual ~Employee();
void set_salary(double new_salary);
virtual string get_name() const;
double get_salary() const;
virtual int getId() const;
string name_;
double salary_;
int id_;
#endif /* EMPLOYEE_H_ */

Both comments and pings are currently closed.

Comments are closed.

Powered by WordPress | Designed by: free css template | Thanks to hostgator coupon and web hosting reviews