So I am confused on where I should start here I believe that I start with an if statement after the cin << price function what do you guys believe I should do from there i'm going to continue working on it and I will update the coding so that if there are any mistake I can get insight on the coding thank you very much.
Complete the program so it will correctly compute the price for an item that may or may not include sales tax. The program asks the user for the type of item (1 for food, 2 for non-food) and the price of the item.
The finished version should only display any calculations if the price entered is a non-zero, positive number. For a positive price of a non-food item, compute the 6% sales tax, add it to the original price. For a positive price of a food item, it doesn’t need to calculate anything.
Your program should display an error message for a zero or negative price and type not equal to 1 or 2. Only if there are no errors, it should display the amount of tax and the new price that must be paid.
amount of tax = original price * tax rate
final price = original price + amount of tax
When you are finished with the program submit it and update the comments at the top of the program. Here are some test cases to verify your output.
Test Case #1
Inputs: type = 1, price = 13.69
Outputs: tax = $0, final price = $13.69
Test Case #2
Inputs: type = 2, rate = 13.69
Output: tax = $0.82, final price = $14.51
using namespace std;
double price = 0.0;
const double TAX = 0.06;
double totalPrice = 0.0;
int type = 0;
cout << fixed; //set precision of output
cout << precision(2);
cout << "Enter type of item (1=food, 2=non food): ";
cin >> type;
cout << "Enter the price of item: ";
cin >> price;
//check for positive #'s for price and type of 1 or 2
//compute tax and add to price if applicable
//display error message for incorrect values
} //end of main function