Thread: Having problems with my current program

  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
    Chappell Hill, Texas
    Posts
    2,332
    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!!!
            {
    Mainframe assembler programmer by trade. C coder when I can.

  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, 02: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