Syntax Error

Hi guys: Can any one please help me in the syntax error on line         if code == 'A'
Thanks.


#include<iostream>
#include<cmath>
#include<iomanip>
using namespace test;

int main()
  {
        double hourlyRates[6] = {11.25, 10.0, 9.85, 8.65, 25.0, 25.0};
        char code = ' ';
        cout << "Pay code (A - F):";
        cin >> code;
        code = toupper(code);
        if code == 'A'
              cout << "Hourly rate: $" << hourlyRates[0] << endl;
        else if code == 'B'
              cout << "Hourly rate: $" << hourlyRates[1] << endl;
        else if code == 'C'
              cout << "Hourly rate: $" << hourlyRates[2] << endl;
        else if code == 'D'
              cout << "Hourly rate: $" << hourlyRates[3] << endl;
        else if code == 'E'
              cout << "Hourly rate: $" << hourlyRates[4] << endl;
        else if code == 'F'
              cout << "Hourly rate: $" << hourlyRates[5] << endl;
        else
              cout << "Invalid pay code" << endl;
        system("pause");
        return 0;
}
mustish1Asked:
Who is Participating?
 
käµfm³d 👽Commented:
"If" statements (and "else if") require parentheses around the condition:
if (code == 'A')

Open in new window

0
 
phoffricCommented:
>> if code == 'A'

Replace with:
     if( code == 'A' )

Similarly:

else( if code == 'B' )
0
 
käµfm³d 👽Commented:
@phoffric

Did you invent a new "else if"    ; )

j/k
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
phoffricCommented:
:) thanks for noticing the typo. Should have been
     else if ( code == 'B' )
0
 
mustish1Author Commented:
lol
thanks just mix the coding style of one language into another.
0
 
phoffricCommented:
I used to have trouble writing C++ and Java in the same day. But compiler errors quickly sorted out the confusion.
0
 
mustish1Author Commented:
Thanks again.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.