I am tring to make a flaot that can work both as a list and a indicater. The list is for each of the states (made floats form them), then to allow each state to have its own percent values within itself. I am confused of the part cause when i tried it just displayed 1 and not the displayed the number value and what the taxe rate for it is. What is the easist way that I can get a float to hold a number value so when the user plugs in that number. It then will take the price number and add a tax (percentage value with it) to it.
float purchase; // float for user entering their purchase amount
float state_list, tax_rate, sales_taxe, total_price;
float maryland, virginia, NC, SC, deleware, DOC, pennsylvania;
int main () {
if (!cin) { // figure out the purchase == no number value so loop works correctly
cin.clear(); // reset failbit
cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
cout << "Please select a state from the following list:";
}
else {
cout << "The entered cost is invalid..." << endl;
cout << endl << "How much is the item you would like to purchase: $";
cin >> purchase;
cout << "Please select a state from the following list:" << endl;
}
cout << endl << "1.) Maryland" << endl;
cout << "2.) Virginia" << endl;
cout << "3.) North Carolina" << endl;
cout << "4.) South Carolina" << endl;
cout << "5.) Deleware" << endl;
cout << "6.) District of Columbia" << endl;
cout << "7.) Pennsylvania" << endl;
cout << "In which state is the purchase being made : ";
cin >> state_list;