Welcome! Please Login or Sign Up.

A Little Help in Creating a Program

Discussion in 'Technology Forum' started by WhIzZaD, Sep 24, 2010.


Thread Status:
Not open for further replies.
  1. Member

    Joined:
    Jun 9, 2007
    Posts:
    69
    Likes:
    12
    Trophy Points:
    16
    I'm pretty sure one of yall dudes know how to do this shit so somebody help me out here lol. im in intro to computer programming and we learning the basic bs but for some reason i cant get this one code to work. the assignment is:

    Develop an algorithm that will determine the gross pay of a particular employee.
    You need to read the hourly rate, and the amount of hours worked by the employee.
    You should display the hours, hourly rate, and gross pay of the employee.
    If the hours worked exceed 40 compute the overtime will be paid 1.5 *hourly rate.

    my code so far is

    Code:
    main () {
        //Declare Variables
        double hours, hourlyRate, grossPay, overTime, overPay; 
    
        //Enter hours & hours worked
        printf("Enter the amount of hours you worked here: \n");
        scanf("%lf", &hours); 
        printf("You have worked %.2lf\n", hours);
        printf("Enter your hourly rate here: \n");
        scanf("%lf", &hourlyRate);
        printf("Your hourly rate is %.2lf\n", hourlyRate);
    
        //Calculate gross pay
        if (hours <= 40);
            grossPay = hours * hourlyRate;
        if (hours > 40); 
            grossPay = (hourlyRate * 1.5) * hours;
        
        //Output gross pay
        printf("Your gross pay is: %.2lf\n", grossPay);
    
        system("pause");
    }
    
    BUT for some reason the gross pay always comes out with the overtime even if its under 40. a little help?
     
    WhIzZaD, Sep 24, 2010


    #1
  2. Classified

    Joined:
    May 23, 2007
    Posts:
    744
    Likes:
    16,060
    Trophy Points:
    421
    shoot rookie a pm if you don't get a reply from anyone else, he's into programming.
     
  3. Elite Member

    Joined:
    Aug 7, 2009
    Posts:
    84
    Likes:
    12
    Trophy Points:
    16
    This looks like C I don't have a C compiler but here this should work.

    Code:
    
    main () {
        //Declare Variables
        double hours, hourlyRate, grossPay, overTime, overPay; 
    
        //Enter hours & hours worked
        printf("Enter the amount of hours you worked here: ");
        scanf("%lf", &hours); 
        printf("Your total hours worked %.2lf\n", hours);
        printf("Enter your hourly rate here: ");
        scanf("%lf", &hourlyRate);
        printf("Your hourly rate is %.2lf\n", hourlyRate);
    
        //Calculations
        if (hours > 40) {
            overTime = (hours - 40);
            overPay = (hourlyRate * 1.5 * (overTime));
            grossPay = (40 * hourlyRate) + overPay;
        } else {
            grossPay = hours * hourlyRate;
        }
        
        
        //Print out
        printf("Your gross pay is: %.2lf\n", grossPay);
    
    }
    
     
  4. Member

    Joined:
    Jun 9, 2007
    Posts:
    69
    Likes:
    12
    Trophy Points:
    16
    thank you sir.
     
  5. VIP

    Joined:
    Sep 23, 2010
    Posts:
    13
    Likes:
    189
    Trophy Points:
    3
    Hey star. What should I do if I hit the "THANKS" button and I cannot get the download link
     
  6. Member

    Joined:
    Sep 4, 2008
    Posts:
    351
    Likes:
    1,245
    Trophy Points:
    71
    thats because there isnt anything to donwload in this thread,or even in the whole "general support" forum.
     
Thread Status:
Not open for further replies.

Share This Page