acount

 1 #include<iostream>
 2 using namespace std;
 3 class account
 4 {
 5 public:
 6     int de( int i, double b, double a)
 7     {
 8         id = i;
 9         balance = b;
10         annuleinterestrate = a;
11         return 0;
12     }
13     int visit( int b)
14     {
15         switch (b)
16         { 
17         case 1:cout << id;
18             return 0;
19         case 2:cout << balance << endl;
20             return 0;
21         case 3:cout << annuleinterestrate << endl;
22             return 0;
23         }
24     }
25     int change(int b)
26     {
27         cout << "Please input the content:" << endl;
28         switch (b)
29         {
30         case 1:cin >> id;
31             return 0;
32         case 2:cin >> balance;
33             return 0;
34         case 3:cin >> annuleinterestrate ;
35             return 0;
36         }
37     }
38     double GetMonthlyInterestRate()
39     {
40         monthlyinterestrate =  annuleinterestrate/12.0;
41         return monthlyinterestrate;
42     }
43     double withDraw()
44     {
45         double q;
46         cout << "please input the number:" <<endl;
47         cin >> q;
48         balance += q;
49         return balance;
50     } 
51     double deposit() 
52     {
53         double q;
54         cout << "please input the number:" <<endl;
55         cin >> q;
56         balance -= q;
57         return balance;
58     }
59 private:
60     int id;
61     double annuleinterestrate,monthlyinterestrate,balance;
62 };
63 int main()
64 {
65     int a,b;
66     account acc;
67     acc.de( 1122,20000,0.045 ) ;
68     cout << "Please intput the function's number: (1 visit; 2 change; 3 GetMonthlyInterestRate;4 withDraw;5 deposit;)" << endl;
69     cin >> a;
70     switch (a)
71     {
72     case 1: cout << "which do you chose?(1 id;2 balance;3 annuleinterestrate)" << endl;
73         cin >> b;
74         acc.visit( b );
75         break;
76     case 2: cout << "which do you chose?(1 id;2 balance;3 annuleinterestrate)" << endl;
77         cin >> b;
78         acc.change( b );
79         break;
80     case 3: cout << acc.GetMonthlyInterestRate() << endl;
81         break;
82     case 4: cout << acc.withDraw() << endl;
83         break;
84     case 5: cout << acc.deposit() << endl;
85         break;
86     }
87     return 0;
88 }

posted on 2013-12-26 16:44  了发发  阅读(379)  评论(0)    收藏  举报

导航