Originally Posted by
pweezy-f
@ crazeeplayer
no mock exams yet. Btw wat year did u do OOP?
long time ago..... roun 07 08 thereabout..... the programming assignments are always d same as they have to follow a set structure... or if they change they change little..... same thing for data structures dat u will do in 3rd year..... jus practise wat him give u..... an wen he give u d mock exam make sure u go through it
Code:
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include <iostream>
#include <conio.h>
#include <stdlib.h>
class Customer {
private:
char name[20];
char address[30];
char city[20];
char pcode[6];
float acc_bal;
public:
Customer:: Customer() { // constructor
acc_bal = 0.00;
}
void getdata() {
cout << "\nEnter your name: "; cin >> name;
cout << "\nEnter your address: "; cin >> address;
cout << "\nEnter your city: "; cin >> city;
cout << "\nEnter your postal code: "; cin >> pcode;
cout << "\nEnter current account balance: "; cin >> acc_bal;
}
void deposit() {
float dep;
cout << "\nEnter amount to be deposited: ";
cin >> dep;
acc_bal += dep;
}
void withdraw() {
float wdraw;
cout << "\nEnter amount to be withdrawn: "; cin >> wdraw;
acc_bal -= wdraw;
}
void showdata() {
cout << "Name: " << name;
cout << "\nAddress: " << address;
cout << "\nCity: " << city;
cout << "\nPostal Code: " << pcode;
cout << "\nAccount Balance: $" << acc_bal << endl;
}
};
int main() {
char choice;
int flag = 0;
int count = 0;
int recnum;
Customer cust[10];
while (flag == 0) {
cout << "\t\t\n\n" << "Main Menu";
cout << "\t\n\n" << "Select by letter:";
cout << "\t\n" << "a - Add a customer.";
cout << "\t\n" << "d - Deposit money.";
cout << "\t\n" << "w - Withdraw money.";
cout << "\t\n" << "s - Show Account Information.";
cout << "\t\n" << "q - Quit Application.\n\n";
cout << "\t" << "Choice: ";
choice = getche();
switch(choice) {
case 'a':
system("cls");
if (count > 10) {
cout << "Can't add anymore records. Press any key to return to main menu.";
getche();
break;
}
count += 1;
cust[count].getdata();
system("cls");
break;
case 'd':
system("cls");
cout << "\nEnter customer number: ";
cin >> recnum;
cust[recnum].deposit();
system("cls");
break;
case 'w':
system("cls");
cout << "\nEnter customer number: ";
cin >> recnum;
cust[recnum].withdraw();
system("cls");
break;
case 's':
system("cls");
cout << "\nEnter customer number: ";
cin >> recnum;
cust[recnum].showdata();
getche();
system("cls");
break;
case 'q':
flag = 1;
break;
default:
cout << "\nInvalid selection. Press a key to return to main menu.";
getche();
}
if (flag == 1) {
break;
}
}
return 0;
}