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
|
#include<iostream>
#include<conio.h>
#include <string>
#include <map>
using namespace std;
float Price = 0.00, SalesTax = 0.00;
double TaxUT = 0.06;
int TaxC = 0;
char ReRun;
const char* State [] = {"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 [] = {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};
int main(void)
{
do
{
cout << "What does your item cost?" << endl;
cin >> Price;
string StateInput;
cout << "What state do you want to calculate tax for?" << endl;
cin >> StateInput;
int i = 0;
for (i = 0; i < 50; i++)
{
if (State[i] == StateInput)
{
TaxC = i;
}
else if (i == 50)
{
cout << "Sorry you must have spelled the state name incorrectly." << endl;
cout << "Do you want to rerun the program?" << endl;
cin >> ReRun;
}
}
SalesTax = Price * Tax[TaxC];
cout << "This is the price of your item in " << StateInput << ":" << endl << "$" << Price + SalesTax << "." << endl;
getch();
}
while (ReRun == 'y' || ReRun == 'Y');
}
|