I am creating a simple program that takes the cost of 5 items a user inputs and finds the subtotal and total with 5% sales tax. I have created the program to adjust the setprecision() value based on what the subtotal cost and total cost come out to (basically so it will always have the .00 ex $100.00 and 10.00)
The problem I am having is I keep getting the debug error
error C2059: syntax error : '>'. I have gone threw the code and found that the problem is relating to my if statement in some same but I cant determine how since it all looks correct.
Hear is the code
CODE
// This application will take 5 items that a user enters and calculate the total price with 5% sales tax
// Introduction to programming C++
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
// Delcares 1-5, Subtotal, SalesTax, and Total which are set to 0.
// Everything except for tax is set to 0 so large default values are not assigned before the users enters in the value being asked
// Once the user enters in the value for the particular item it will be stored as that new value
double item1=0, // Declares items 1-5
item2=0,
item3=0,
item4=0,
item5=0,
stotal=0,// Delcares subtotal
stax=0, // Delcares Sales Tax
total=0; // Declares Total
const double tax=.05; //Declared amount of tax (5% = .05) as a constant since it will never change in the application
int x=4; // Value for setprecision
// Display message to user explaining what the application dose
cout << "This applicaiton will calculate the total cost of 5 items with 5% sales tax\n" << endl;
// Ask user for cost of item 1
cout << "\nPlease enter the cost of item 1: $";
// Users input for item 1
cin >> item1;
// Ask user for cost of item 2
cout << "\nPlease enter the cost of item 2: $";
// Users input for item 2
cin >> item2;
// Ask user for cost of item 3
cout << "\nPlease enter the cost of item 3: $";
// Users input for item 3
cin >> item3;
// Ask user for cost of item 4
cout << "\nPlease enter the cost of item 4: $";
// Users input for item 4
cin >> item4;
// Ask user for cost of item 5
cout << "\nPlease enter the cost of item 5: $";
// Users input for item 5
cin >> item5;
// Sub total = the sum of items 1-5
stotal = item1 + item2 + item3 + item4 + item5;
// Sales tax = subtoal * tax (5%)
stax = stotal*tax;
// Total = sales tax + subtotal
total = stax + stotal;
if (stotal => 100 && total => 100)
x=5;
cout << showpoint << "\nSubtotal: $" << setprecision(x) << stotal;
cout << showpoint << "\nSales Tax: 5.0%";
cout << "\n****************";
cout << showpoint << "\nTotal: $" << setprecision(x)<< total;
cout << "\n****************" << endl;
// Will pause application
system("Pause");
return 0;
}
I have set the int x=4 so if stotal and total => 100 it will get place 4 in setprecision(x).
This post has been edited by lockdown: 1 Oct, 2007 - 03:13 PM