注册 登录
编程论坛 C++教室

求解一题面向对象的题目

neil86918 发布于 2010-04-14 13:59, 385 次点击
小弟刚接触C++ OOP程序 希望各位能给点提示 谢谢

The file, bill.dat contains information related to a customer’s account number and its 6-month bill amount. The data is stored one per line, i.e. account number followed by the bill of each month. A sample of the data is as shown below.
123  (AccountNumber)
10   (6 months bill)
20
30
40
50
60
.
.
.
.
124
11
12
13
14
15
16

Customer Class Specification
class Customer
{
private:
int acctNo;
double billAmt;
public:
Customer(void);
int getAcctNo(); // return acctNo
void setAcctNo(int); // set acctNo to the given value
double getBillAmt(); // return billAmt
void setBillAmt(double); // set billAmt to the given value
};

(a) Write code to implement the Customer Class


(b) Write a main program that fulfils the following requirements:
1. reads the data from the file, bill.dat
2. populates the array of Customers with the read-in data
3. display the account number and total bill of this array of Customers.
For this program, you may assume that there are only 5 customers. A sample screen is as shown below. You are expected to write code to format the display.
Billing Summary
===============
Account Number Total Bill Amount
123    $210
124    $81
125    $141
126    $330
0 回复
1