hi every1
i want to ask what wrong with my program
it all work allright just the zakat function when i run the program the output is garpege
here is the code
#include <iostream.h>
#include <conio.h>
#include <stdlib.h>
class Customer {
private:
char name[20];
char address[30];
char city[20];
char pcode[6];
float acc_bal;
double zak;
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 zakat()
{
zak= (acc_bal*2.5)/100;
}
void showdata() {
cout << "Name: " << name;
cout << "\nAddress: " << address;
cout << "\nCity: " << city;
cout << "\nPostal Code: " << pcode;
cout << "\nAccount Balance: $" << acc_bal << endl;
cout<<"Zakat is: "<<zak<<endl;
}
};
int main() {
char choice;
bool flag =0;
int count = 0;
int recnum;
Customer cust[10];
while (flag == false) {
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: ";
cin>>choice ;
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 == true) {
break;
}
}
return 0;
}