The variable 'number' is being used without being initialized?

i dont know what I am doing wrong?
# include <iostream>
# include <string>
# include <iomanip>
using namespace std;

int main ()
{ int accountNumber;
char accountType;
int savingFee;
int checkingFee;
int number;
double Balance;
const double Saving_account_interest=0.04;
const double Checking_account_special=0.03;
const double Checking_account_regular=0.05;
const double Saving_account_fee=10;
const double Checking_account_fee=25;
cout<<fixed<<showpoint;
cout<<setprecision(2);
cout<<"Please input your account number";
cin>>accountNumber;

std::cin.get();
std::cin.get();

cout<<endl;

cout<<"Enter account type:"
<< "S or s (Saving),"
<< "C or c (Checking),";
cin>>accountType;
cout<<endl;

switch (accountType)
{
case 's':
case 'S':
cout <<"enter the number";
cin>>accountType;
if(number>5000)
Balance=number*Saving_account_interest;
else (number<5000);
Balance=number*Saving_account_interest+Saving_account_fee;


break;

case 'c':
case 'C':
cout <<"enter the number";
if (number>5000)
Balance=number*Checking_account_special;
else (number<5000);
Balance=number*Checking_account_regular+Checking_account_fee;

break;
default:
cout<<"Invalid account type."<<endl;
return 0;
}



}
that compiles fine for me, i imagine you have warnings turned on on your compiler or something. i believe it's referring to this code:

1
2
3
4
cout <<"enter the number";
cin>>accountType;
if(number>5000)
Balance=number*Saving_account_interest;


i think in the second line you want to be writing to number. otherwise, you haven't stored anything in number, so it just contains garbage. then you're multiplying garbage and assigning it to another variable
Hey, thanks for the reply.But when I enter the account number, the command prompts get away.I already changed the program:
# include <iostream>
# include <string>
# include <iomanip>
using namespace std;

int main ()
{ int accountNumber;
char accountType;
int savingFee;
int checkingFee;
double number;
double Balance;
const double Saving_account_interest=0.04;
const double Checking_account_special=0.03;
const double Checking_account_regular=0.05;
const double Saving_account_fee=10;
const double Checking_account_fee=25;
cout<<fixed<<showpoint;
cout<<setprecision(2);
cout<<"Please input your account number";
cin>>accountNumber;

std::cin.get();
std::cin.get();

cout<<endl;

cout<<"Enter account type:"
<< "S or s (Saving),"
<< "C or c (Checking),";
cin>>accountType;
cout<<endl;

switch (accountType)
{
case 's':
case 'S':
cout <<"enter the number";
number=1000;
if(number>=5000)
number=number*Saving_account_interest;
else (number<=5000);
number=number*Saving_account_interest+Saving_account_fee;


break;

case 'c':
case 'C':
cout <<"enter the number";
number=1000
if (number>5000)
number=number*Checking_account_special;
else (number<5000);
number=number*Checking_account_regular+Checking_account_fee;

break;
default:
cout<<"Invalid account type."<<endl;

std::cin.get();
std::cin.get();
std::cin.get();
std::cin.get();
and the command prompt vanish less than a second and it states The program '[1060] march_19.exe: Native' has exited with code 0 (0x0).
Topic archived. No new replies allowed.