1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
/* Usandfriend's code for Concise way to Get Stuff. */
#include <iostream>
main()
{
double SalesTax,price;
std::string state;
int TaxC,i;
std::string State [50] = {"Alabama", "Alaska", "Arizona", "Arkansas", "California",
"Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Idaho",
"Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland",
"Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana",
"Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York",
"North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania",
"Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah",
"Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming"};
double Tax [57] = {0.04,0.00,0.066,0.06,0.0725,0.029,0.0635,0.00,0.06,
0.04,0.04,0.06,0.0625,0.07,0.06,0.063,0.06,0.04,0.05,0.06,0.0625,0.06,
0.06875,0.07,0.04225,0.00,0.055,0.0685,0.00,0.07,0.04225,0.00,0.055,
0.0685,0.00,0.07,0.05125,0.04,0.0475,0.05,0.055,0.045,0.00,0.06,0.07,0.06,
0.04,0.07,0.0625,0.0595,0.06,0.05,0.065,0.06,0.05,0.04,0.06};
while(true)
{
std::cout<<"If you need help on states and how to enter them, please enter \"help\" when you get to states. If you enter something wrong, the program might not work."<<std::endl<<std::endl;
std::cout<<"What does your item cost? ";
std::cin>>price;
std::cin.ignore();
while(true)
{
std::cout<<"What state do you want to calculate tax for? ";
std::getline(std::cin,state);
if(state=="help")
{
std::cout<<"Here are the list of states:"<<std::endl;
for(i=0;i<50;i++)
{
std::cout<<i+1<<". "<<State[i]<<std::endl;
}
std::cout<<"An example of putting in a state is: \"West Virginia\"."<<std::endl<<std::endl;
}
else
{
break;
}
}
for (i = 0; i < 50; i++)
{
if (State[i]==state)
{
TaxC = i;
break;
}
}
SalesTax = price*Tax[TaxC];
std::cout<<"Final Price is: "<<price + SalesTax;
std::cin.ignore();
while(true)
{
std::cout<<std::endl<<std::endl<<"Would you like to rerun the program (enter \"yes\" or \"no\")? ";
std::getline(std::cin,state);
if((state=="no"))
{
break;
}
else if (state=="yes")
{
main();
}
else
{
std::cout<<"Invalid option."<<std::endl;
}
std::cout<<std::endl<<std::endl<<std::endl;
}
break;
}
}
| |