| | |
what's wrong
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Apr 2005
Posts: 129
Reputation:
Solved Threads: 0
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
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
C++ Syntax (Toggle Plain Text)
#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; }
![]() |
Similar Threads
- My CD-RW plays but won't burn. What could be wrong?? Help Please? (Storage)
- Retrieve email I sent to the wrong person (Web Browsers)
- Ram voltage wrong?? (Motherboards, CPUs and RAM)
- Am I going about this the wrong way (IT Professionals' Lounge)
- wats wrong with imesh??? (Windows NT / 2000 / XP)
Other Threads in the C++ Forum
- Previous Thread: CPU Task Scheduler
- Next Thread: Help! I'm new to pointers
Views: 1206 | Replies: 0
| Thread Tools | Search this Thread |
Tag cloud for C++
6 api application array arrays assignment based beginner binary c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete developer display dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator givemetehcodez graph iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multidimensional multiple newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg search sort sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets





