A consise way to get stuff.

Pages: 123
Okay I think i have got it down tell me if anyone finds any errors with this code thanks :D

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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include <iostream>
#include <string>
#include <map>
#include <conio.h>
#include <limits>
#include <functional>
#include <algorithm>

using namespace std;

string ReRun;
map <string, float> TaxMap;

int main ()
{   
    TaxMap 	["alabama"             ] =  0.0400;
    TaxMap 	["alaska"              ] =  0.0000;
    TaxMap 	["arizona"             ] =  0.0660;
    TaxMap 	["arkansas"            ] =  0.0600;
    TaxMap 	["california"          ] = 	0.0625;
    TaxMap 	["colorado"            ] = 	0.0290;
    TaxMap 	["connecticut"         ] = 	0.0635;
    TaxMap 	["delaware"            ] = 	0.0000;
    TaxMap 	["district of columbia"] = 	0.0600;
    TaxMap 	["florida"             ] = 	0.0600;
    TaxMap 	["georgia"             ] = 	0.0400;
    TaxMap 	["hawaii"              ] = 	0.0400;
    TaxMap 	["idaho"               ] = 	0.0600;
    TaxMap 	["illinois"            ] = 	0.0625;
    TaxMap 	["indiana"             ] = 	0.0700;
    TaxMap 	["iowa"                ] = 	0.0600;
    TaxMap 	["kansas"              ] = 	0.0630;
    TaxMap 	["kentucky"            ] = 	0.0600;
    TaxMap 	["louisiana"           ] = 	0.0400;
    TaxMap 	["maine"               ] = 	0.0500;
    TaxMap 	["maryland"            ] = 	0.0600;
    TaxMap 	["massachusetts"       ] = 	0.0625;
    TaxMap 	["michigan"            ] = 	0.0600;
    TaxMap 	["minnesota"           ] = 	0.0688;
    TaxMap 	["mississippi"         ] = 	0.0700;
    TaxMap 	["missouri"            ] = 	0.0423;
    TaxMap 	["montana"             ] = 	0.0000;
    TaxMap 	["nebraska"            ] = 	0.0550;
    TaxMap 	["nevada"              ] = 	0.0685;
    TaxMap 	["new hampshire"       ] = 	0.0000;
    TaxMap 	["new jersey"          ] = 	0.0700;
    TaxMap 	["new mexico"          ] = 	0.0513;
    TaxMap 	["new york"            ] = 	0.0400;
    TaxMap 	["north carolina"      ] = 	0.0475;
    TaxMap 	["north dakota"        ] = 	0.0500;
    TaxMap 	["ohio"                ] = 	0.0550;
    TaxMap 	["oklahoma"            ] = 	0.0450;
    TaxMap 	["oregon"              ] = 	0.0000;
    TaxMap 	["pennsylvania"        ] = 	0.0600;
    TaxMap 	["rhode island"        ] = 	0.0700;
    TaxMap 	["south carolina"      ] = 	0.0600;
    TaxMap 	["south dakota"        ] = 	0.0400;
    TaxMap 	["tennessee"           ] = 	0.0700;
    TaxMap 	["texas"               ] = 	0.0625;
    TaxMap 	["utah"                ] = 	0.0470;
    TaxMap 	["vermont"             ] = 	0.0600;
    TaxMap 	["virginia"            ] = 	0.0400;
    TaxMap 	["washington"          ] = 	0.0650;
    TaxMap 	["west virginia"       ] = 	0.0600;
    TaxMap 	["wisconsin"           ] = 	0.0500;
    TaxMap 	["wyoming"             ] = 	0.0400;
    
    do 
    {
     string State;
     float Tax, Cost;
    
     cout << "How much does your item cost? " << flush;
     cin >> Cost;
     
     cin.ignore(numeric_limits<streamsize>::max(), '\n') ;
    
     cout << "Enter a state: ";
     getline(cin,State);
    
     transform( State.begin(), State.end(), State.begin(), ptr_fun <int, int> (tolower) );
    
     if(TaxMap.find(State) == TaxMap.end())
     {
       transform( State.begin(), State.end(), State.begin(), ptr_fun <int, int> (toupper) );
       cout << "State Not Found: " << State << endl;
     }
     else
     {
       Tax = TaxMap[State];
       transform( State.begin(), State.end(), State.begin(), ptr_fun <int, int> (toupper) );
       cout << "The cost of your item in '" << State << "' is $" << (Tax * Cost) + Cost << ".";
     }

    cout << "\n\nKeep running? \n1.Yes\n2.No\n";
    cin >> ReRun;
    }
    while(ReRun == "Yes" || ReRun == "Y" || ReRun=="1" || ReRun == "y");
    return 0;
}
closed account (18hRX9L8)
One last thing, add ReRun == "yes" (uncapitalized 'y') to line 98.
Topic archived. No new replies allowed.
Pages: 123