I just finished my little tax calc program, not the best, but I am trying to learn how to use structs, so just started with something basic. Heres the code:
Code:
#include <iostream.h>
struct MONEY
{
double hours, pay, total, gross, taxes;
};
int main()
{
MONEY di;
int input;
bool end_prog = 0;
while (end_prog != 1)
{
/* begining commentary*/
cout <<" this program outputs how much taxes you will pay a week,\n"
<< " month, or year, based upon your choice.\n"
<<" the tax % is based upon income, the rates are :\n\n"
<< " 1. 5% if income <20,000\n"
<< " 2. 10% if 20000<income < 40000\n"
<< " 3. 15% if 40000< income < 60000\n\n";
cout <<" enter Hours worked: ";
cin >> di.hours;
cout <<"\n\n";
cout << "enter pay per hour : ";
cin >> di.pay;
cout <<"\n\n";
di.total = di.pay * di.hours;
di.gross = di.total * 52;
/*calculation of taxes based on income*/
if (di.gross < 20000)
{
di.taxes = ((di.total/100 * 5)) ;
}
else if(20000 < di.gross < 40000)
{
di.taxes = ((di.total/100 * 10));
}
else if (40000 < di.gross < 60000)
{
di.taxes = ((di.total/100 * 15));
}
cout << "how long of a period do you want taxes calculated?\n\n"
<< " 1. a week\n"
<< " 2. a month\n"
<< " 3. a year\n";
cin >> input;
cout << "you make "<< di.total <<" dollars a week \n";
cout << (di.total * 4) <<" dollars a month\n";
cout << " and" <<(di.total * 52)<<" dollars a year\n\n";
switch (input)
{
case 1:
cout <<"you pay $" << (di.taxes) <<" dollars in taxes a week\n\n\n";
break;
case 2:
cout <<"you pay $" << (di.taxes * 4) << "dollars in taxes a month\n\n\n";
break;
case 3:
cout <<"you pay $" << (di.taxes * 52) <<" dollars in taxes a year\n\n\n";
break;
}
cout <<" do you want to quit?\n"
<< " Y or N: ";
cin >> input;
if (input == 'Y' || 'y')
{
end_prog = 1;
cout <<endl;
}
else if ( input == 'N' || 'n')
{
end_prog = 0;
cout << "\n\n\n";
}
}
return 0;
}
and I am attaching the .cpp file for anyone who wants to use it.. Any suggestions? I am learning alot, having only really been with C++ for 2 weeks working straight