Well I am working on something that add's up any bills a person may have , but I want to have a loop that asks the user each time it starts do ayou have a bill if 'Y' then it goes and gets the bill amount then at the end it repeats and ask's the same things, but if the user does have more than 1 bill i need a loop that would keep track of each data input then add all of them up at the very end when the user puts 'N' for no.
#include <iostream>
#include <iomanip>
usingnamespace std;
double PayRate;
double Extra;
double Bill;
double Personal;
double Total;
double End_total;
double Bill_total;
double Hours;
int more;
int main()
{
cout<<"Please enter your pay rate\n";
cin >> PayRate;
cout<<"Thank You\n";
cout<<"Please enter your total hours worked\n";
cin>>Hours;
cout<<"Thank You\n";
cout<<"Please enter any extra income this week\n";
cin>>Extra;
cout <<"Thank you.... one moment while totals are calculated\n";
Total = PayRate*Hours-0.22+Extra;
for (int Bill=0; Bill!=-1;Bill++)
{
cout<<"do you have a bill youd like to enter?\n";
cin>>Bill;
cout<<"Thank you"<<endl;
}
cout<<Bill<<endl;
system("pause");
}
#include <iostream>
#include <iomanip>
usingnamespace std;
double PayRate;
double Extra;
double Bill;
double Personal;
double Total;
double End_total;
double Bill_total;
double Hours;
int more;
int main()
{
cout<<"Please enter your pay rate\n";
cin >> PayRate;
cout<<"Thank You\n";
cout<<"Please enter your total hours worked\n";
cin>>Hours;
cout<<"Thank You\n";
cout<<"Please enter any extra income this week\n";
cin>>Extra;
cout <<"Thank you.... one moment while totals are calculated\n";
Total = PayRate*Hours-0.22+Extra;
char ans = NULL;
while(1>0)
{
cout<<"do you have a bill youd like to enter?\n";
cin>>ans;
if(ans == 'y' || ans == 'Y')
{
cout<<"Enter the amount of the bill.\n";
cin>>Bill;
Bill_total += Bill;
continue;
}
if(ans == 'n' || ans == 'N')
{
break;
}
else
{
cout<<"Invalid Choice try again.\n";
}
}
cout<<Bill_total<<endl;
system("pause");
}
that should work, I tried it out.
EDIT: Oh yea and when you post code use the <> thing under format, it looks much nicer and it's easier to read.