c++ - My program can't run accountType as a variable -


#include <iostream> #include <iomanip> using namespace std; int main () {     int accountnumber;     float minimumbalance, currentbalance;     char accounttype;      const float savings_service_charge = 10.00;     const float checking_service_charge = 25.00;     const float savings_interest_rate = 0.04;     const float checking_low_interest_rate = 0.03;     const float checking_average_interest_rate = 0.05;      cout <<"please details of account"<< endl;     cin >> accountnumber,accounttype,minimumbalance,currentbalance;      switch (accounttype){          case 's':         case 's':             cout <<"account number"<<accountnumber<<endl;             cout <<fixed<<showpoint<<setprecision(2);             cout <<"account type:savings"<<endl;             cout <<"minimum balance: $"<<minimumbalance << endl;             cout <<"current balance: $"<<currentbalance << endl;              if (currentbalance < minimumbalance) {                 cout <<"service fee:$"<<savings_service_charge<<endl;}              else {                 cout <<"interest earned:$"<<currentbalance * savings_interest_rate    << "at" << savings_interest_rate*100<<"p%.a"<<endl;             }             break;          case 'c':         case 'c':             cout <<"account number"<<accountnumber<<endl;             cout <<fixed<<showpoint<<setprecision(2);             cout <<"account type:checking"<<endl;             cout <<"minimum balance:$"<<minimumbalance<<endl;             cout <<"current balance:$"<<currentbalance<<endl;              if (currentbalance < minimumbalance) {                 cout <<"service fee:$"<<checking_service_charge<<endl;}             else if (currentbalance <= (minimumbalance+5000.00)){                 cout <<"interest earned:$"<<currentbalance * checking_low_interest_rate <<"at"<<checking_low_interest_rate*100 <<"%p.a"<<endl;             }else {                 cout <<"interest earned:$"<<currentbalance *      checking_average_interest_rate<< "at"<< checking_average_interest_rate*100     <<"%p.a"<<endl;             }             break;         default:             cout <<"error"<<endl;             return 1;             break;     }      system ("pause");     return 0; } 

my program can't read accounttype variable. should make run variable? please tell me step step , error , make work.

as comments tell

cin >> accountnumber,accounttype,minimumbalance,currentbalance; 

is wrong, since taking 1 input multiple variables, if want right, should use >> operator every variable.

cin >> accountnumber >> accounttype >> minimumbalance >> currentbalance; 

which equals same as

cin >> accountnumber; cin >> acccounttype; ... 

in opinion not use global namespace usings, that's sure other topic.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -