I am trying to create a program that takes a car year and weight inputted from the user and determines the weight class and registration fee. This is what my code looks like but I am getting an expected primary-expression before 'int' error. Could someone please help me.

#include <stdlib.h>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
/* Declare variables */
int year, weight;
int class = 0;

/* Obtain input from user*/
cout<<"Enter the year of the car: ";
cin>>year;
cout<<"Enter the weight of the car in pounds: ";
cin>>weight;

/* Perform registration fee calculation*/   
if (weight < 2700 && year <= 1970)
   class=1;
else if (weight >= 2700 && weight <= 3800 && year <= 1970)
   class=2;
else if (weight > 3800 && year <= 1970)
   class=3;
else if (weight < 2700 && year > 1970 && year < 1980)
   class=4;
else if (weight >= 2700 && weight <= 3800 && year > 1970 && year < 1980)
   class=5;
else if (weight > 3800 && year > 1970 && year < 1980)
   class=6;
else if (weight < 3500 && year >= 1980)
   class=7;
else (weight >= 3500 && year >= 1980)
   class=8;
     
switch (class)
{
       case 1:
            cout<<"Your registration fee is $16.50";
            break;
       case 2:
            cout<<"Your registration fee is $25.50";
            break;
       case 3:
            cout<<"Your registration fee is $46.50";
            break;
       case 4:
            cout<<"Your registration fee is $27.00";
            break;
       case 5:
            cout<<"Your registration fee is $30.50";
            break;
       case 6:
            cout<<"Your registration fee is $52.50";
            break;
       case 7:
            cout<<"Your registration fee is $19.50";
            break;
       case 8:
            cout<<"Your registration fee is $52.50";
            break;
}      
    system("PAUSE");
    return EXIT_SUCCESS;
}
Comments
CODETAGS!!

Well, first, "class" is a c++ keyword, you can't use that name.
Second, that last else in your code should be:
else if (weight >= 3500 && year >= 1980)
or:
else

Because else means "if nothing before is true", it can't have an expression to evaluate.

This article has been dead for over six months. Start a new discussion instead.