Having problems with my current program

This is a discussion on Having problems with my current program within the C++ Programming forums, part of the General Programming Boards category; I'm currently taking a starter-course in programming at college, but its an online class so not much 'help' when you ...

  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    6

    Having problems with my current program

    I'm currently taking a starter-course in programming at college, but its an online class so not much 'help' when you get problems, I've been staring at my code for a long time but can't seem to get this error fixed

    Heres my code:

    Code:
    #include <iostream>
    
    using std::cout;
    using std::cin;
    using std::endl;
    
    int main()
    {
        int registrants = 0;
        double totalFee = 0.0;
        
        cout << "Enter number of registrants: ";
        cin >> registrants;
        
        if (registrants <= 0)
        
        cout << "Input Error";
        
        else
        {
            if (registrants >= 1 && registrants <= 5)
            
            totalFee = registrants*100;
            
            cout << "Total fee: " << totalFee << endl;
            
            else                   <--- Error is here!!!
            {
                if (registrants >= 6 && registrants <= 10)
                
                totalFee = registrants*80;
                
                cout << "Total fee: " << totalFee << endl;
                
                else
                {
                    totalFee = registrants*60;
                    
                    cout << "Total fee: " << totalFee << endl;
                 }  
             } 
         }           
                    
                    system("pause");
                    return 0;   
    }
    I keep getting the 2 same errors "Expected primary-expression before "else" and "Expected ';' before "else" but for every other program I've made for class, it looks just like this and no errors at all. Please help!
    Last edited by masterofwar14; 09-16-2009 at 02:42 PM. Reason: (Spelling errors)

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Katy, Texas
    Posts
    2,309
    You might need some curly braces
    Code:
       else
        {
            if (registrants >= 1 && registrants <= 5){
            
            totalFee = registrants*100;
            
            cout << "Total fee: " << totalFee << endl;
            }
            else                   <--- Error is here!!!
            {
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

  3. #3
    Registered User
    Join Date
    Sep 2009
    Posts
    6
    Alas! it worked!, thank you a bunch Dino ^^

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problems with my c letter count program
    By cram55 in forum C Programming
    Replies: 10
    Last Post: 05-30-2007, 04:10 AM
  2. GPA Program Problems
    By Clint in forum C Programming
    Replies: 3
    Last Post: 04-28-2005, 10:45 AM
  3. Replies: 3
    Last Post: 03-04-2005, 01:46 PM
  4. Replies: 0
    Last Post: 04-27-2003, 02:04 AM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21