below are a part of my program ... the problem here is ... when i run the 1st option (1. Open an account) ... it display my cout ... but skipped my cin ...
anyone mind to explain to me ?Code:#include <iostream> #include <string> #include <iomanip> using namespace std; class acc { public: void initial(); void deposit(); void withdraw(); void display(); private: string name; int accno; string type; float balance; }; void acc::initial() { cout << "Name: "; getline(cin, name); cout << "Account No: "; cin >> accno; cout << "Account type: "; cin >> type; cout << "Initial amount: "; cin >> balance; } void acc::deposit() { float dep; cout << "Deposit: "; cin >> dep; balance += dep; } void acc::withdraw() { float draw; cout << "Withdraw: "; cin >> draw; if(balance < draw) cout << "Insufficient amount in your balance" << endl; else balance -= draw; } void acc::display() { cout << "Name: " << name << endl; cout << "Account No.: " << accno << endl; cout << "Account Type: " << type << endl; cout.setf(ios::fixed); cout << "Balance: " << setprecision(2) << balance << endl; } int main() { system("color 1F"); acc x; int option; while(true) { cout << "\t\t\t1. Open an account" << endl; cout << "\t\t\t2. Deposit money" << endl; cout << "\t\t\t3. Withdraw money" << endl; cout << "\t\t\t4. Show info" << endl; cout << "\t\t\t5. Exit\n" << endl; cout << "\t\t\tChoose an option: "; cin >> option; switch(option) { case 1: cout << "\n"; x.initial(); system("pause"); system("cls"); break; case 2: cout << "\n"; x.deposit(); system("pause"); system("cls"); break; case 3: cout << "\n"; x.withdraw(); system("pause"); system("cls"); break; case 4: cout << "\n"; x.display(); system("pause"); system("cls"); break; case 5: exit(1); } } return 0; }



LinkBack URL
About LinkBacks



....