D
D
I'm new to C++ so please excuse the bad coding but I'm having problems
getting my program to loop. It should continue to ask for more
amounts and calculate them properly but it just iterates once and then
finishes. Any suggestions would be appreciated. Here is what I have:
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
float percent,baseAmount,taxIncome,taxDue,lowerLimit;
cout <<setw(42) <<"TAX TABLE"<<endl;
cout <<"Taxable Income"<<"\t\t\t\t\t\t\t"<<"Of Amount"<<endl;
cout <<"Over --"<<"\t\t"<<"But Not Over --"<<"\t\t"<<"Your Tax Is
--"<<"\t\t"<<"Over--"<<endl;
cout <<"$0"<<"\t\t"<<"$25,350"<<"\t\t\t"<<"$0 +
15%"<<"\t\t"<<"$0"<<endl;
cout <<"$25,350"<<"\t\t"<<"$61,400"<<"\t\t\t"<<"$3,802 +
28%"<<"\t\t"<<"$25,350"<<endl;
cout <<"$61,400"<<"\t\t"<<"$128,100"<<"\t\t"<<"$13,896 +
31%"<<"\t\t"<<"$61,400"<<endl;
cout <<"$128,100"<<"\t"<<"$278,450"<<"\t\t"<<"$34,573 +
36%"<<"\t\t"<<"$128,100"<<endl;
cout <<"$278,450"<<"\t\t\t\t"<<"$86,699 +
39.6%"<<"\t\t"<<"$278,450"<<endl;
cout <<"\n";
cout <<setw(42) <<"TAX OUTPUT" <<endl;
cout <<"Taxable Income" "\t\t\t" "Tax Due\n";
cout <<"--------------" "\t\t\t" "-------\n";
cout <<"?" "\t\t\t\t" "?\n";
cout <<"?" "\t\t\t\t" "?\n";
cout <<"?" "\t\t\t\t" "?\n";
cout <<"?" "\t\t\t\t" "?\n";
cout <<"?" "\t\t\t\t" "?\n";
cout <<"\n";
cout <<"I'm going to calculate your tax due based on your income.\n";
cout <<"Your tax due will be using the Tax Table and then print out
\n";
cout <<"the results on the Output Table with your tax due amount.\n";
cout <<"Please enter your taxable income in whole dollars.\n";
cin >>taxIncome;
while (taxIncome >=0)
{
if (taxIncome <=25,350)
{
baseAmount = 0;
lowerLimit = 0;
percent = 15;
}
else if (taxIncome <=61,400)
{
baseAmount = 3,802;
lowerLimit = 35,350;
percent = 28;
}
else if (taxIncome <=128,100)
{
baseAmount = 13,896;
lowerLimit = 61,400;
percent = 31;
}
else if (taxIncome <=278,450)
{
baseAmount = 34,573;
lowerLimit = 128,100;
percent = 36;
}
else
{
baseAmount = 86,699;
lowerLimit = 278,450;
percent = 39.6;
}
taxDue = baseAmount + (taxIncome - lowerLimit) * percent /100;
cout <<"Here is your taxable income "<<taxIncome <<endl;
cout <<"And here is your tax due "<<taxDue<<endl;
cout <<"Please enter your next amount\n";
cin>>taxIncome;
return 0;
}
}
getting my program to loop. It should continue to ask for more
amounts and calculate them properly but it just iterates once and then
finishes. Any suggestions would be appreciated. Here is what I have:
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
float percent,baseAmount,taxIncome,taxDue,lowerLimit;
cout <<setw(42) <<"TAX TABLE"<<endl;
cout <<"Taxable Income"<<"\t\t\t\t\t\t\t"<<"Of Amount"<<endl;
cout <<"Over --"<<"\t\t"<<"But Not Over --"<<"\t\t"<<"Your Tax Is
--"<<"\t\t"<<"Over--"<<endl;
cout <<"$0"<<"\t\t"<<"$25,350"<<"\t\t\t"<<"$0 +
15%"<<"\t\t"<<"$0"<<endl;
cout <<"$25,350"<<"\t\t"<<"$61,400"<<"\t\t\t"<<"$3,802 +
28%"<<"\t\t"<<"$25,350"<<endl;
cout <<"$61,400"<<"\t\t"<<"$128,100"<<"\t\t"<<"$13,896 +
31%"<<"\t\t"<<"$61,400"<<endl;
cout <<"$128,100"<<"\t"<<"$278,450"<<"\t\t"<<"$34,573 +
36%"<<"\t\t"<<"$128,100"<<endl;
cout <<"$278,450"<<"\t\t\t\t"<<"$86,699 +
39.6%"<<"\t\t"<<"$278,450"<<endl;
cout <<"\n";
cout <<setw(42) <<"TAX OUTPUT" <<endl;
cout <<"Taxable Income" "\t\t\t" "Tax Due\n";
cout <<"--------------" "\t\t\t" "-------\n";
cout <<"?" "\t\t\t\t" "?\n";
cout <<"?" "\t\t\t\t" "?\n";
cout <<"?" "\t\t\t\t" "?\n";
cout <<"?" "\t\t\t\t" "?\n";
cout <<"?" "\t\t\t\t" "?\n";
cout <<"\n";
cout <<"I'm going to calculate your tax due based on your income.\n";
cout <<"Your tax due will be using the Tax Table and then print out
\n";
cout <<"the results on the Output Table with your tax due amount.\n";
cout <<"Please enter your taxable income in whole dollars.\n";
cin >>taxIncome;
while (taxIncome >=0)
{
if (taxIncome <=25,350)
{
baseAmount = 0;
lowerLimit = 0;
percent = 15;
}
else if (taxIncome <=61,400)
{
baseAmount = 3,802;
lowerLimit = 35,350;
percent = 28;
}
else if (taxIncome <=128,100)
{
baseAmount = 13,896;
lowerLimit = 61,400;
percent = 31;
}
else if (taxIncome <=278,450)
{
baseAmount = 34,573;
lowerLimit = 128,100;
percent = 36;
}
else
{
baseAmount = 86,699;
lowerLimit = 278,450;
percent = 39.6;
}
taxDue = baseAmount + (taxIncome - lowerLimit) * percent /100;
cout <<"Here is your taxable income "<<taxIncome <<endl;
cout <<"And here is your tax due "<<taxDue<<endl;
cout <<"Please enter your next amount\n";
cin>>taxIncome;
return 0;
}
}