Error
Sep 28, 2012 at 4:48pm UTC
When I run this program, I get the following errors
Error 1 error C2146: syntax error : missing ';' before identifier 'total'(line 25)
3 IntelliSense: expected a ';' (line 25)
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
#include <iomanip>
#include <iostream>
using namespace std;
int main()
{
double item1, item2, item3, item4, item5, subtotal, tax, total;
cin >> item1;
cout << "Enter the price of item 2: " ;
cin >> item2;
cout << "Enter the sales for item 3: " ;
cin >> item3;
cout << "Enter the price of item 4: " ;
cin >> item4;
cout << "Enter the price of item 5: " ;
cin >> item5;
subtotal = item1 + item2 + item3 + item4 + item5;
tax = .06 * (item1 + item2 + item3 + item4 + item5)
total = tax + subtotal;
cout << "\Subtotal\n" ;
cout << "-------------\n" ;
cout << setprecision(2) << fixed;
cout << "Item 1: " << setw(8) << item1 << endl;
cout << "Item 2: " << setw(8) << item2 << endl;
cout << "Item 3: " << setw(8) << item3 << endl;
cout << "Item 4: " << setw(8) << item4 << endl;
cout << "Item 5: " << setw(8) << item5 << endl;
cout << "Subtotal: " << setw(8) << subtotal << endl;
cout << "Tax: " << setw(8) << tax << endl;
cout << "Total: " << setw(8) << total << endl;
system("PAUSE" );
return 0;
}
Anyone know how to fix?
Sep 28, 2012 at 4:55pm UTC
simply replace
tax = .06 * (item1 + item2 + item3 + item4 + item5)
with
tax = .06 * (item1 + item2 + item3 + item4 + item5);
you forgot a semi-colon ^.^.
Sep 28, 2012 at 4:55pm UTC
I do not see here a semicolon
tax = .06 * (item1 + item2 + item3 + item4 + item5)
Topic archived. No new replies allowed.