salary program heeeelp!

This is a discussion on salary program heeeelp! within the C Programming forums, part of the General Programming Boards category; This is a program to calculate salary. (at least to try to=). Well, it is supposed that all the information ...

  1. #1
    pancho
    Guest

    Question salary program heeeelp!

    This is a program to calculate salary. (at least to try to=). Well, it is supposed that all the information is given by the user. For the first 40 hours or less the salary is equal to rate * hours. After 40 hours the salary =(additional hours )* (1.5 *rate) rate + (rate*40)
    What I am doing wrong???
    thanks


    #include <stdio.h>

    int main()
    {
    float salary;
    int rate, hours;



    printf( "Enter # of hours worked (-1 to end): " );
    scanf( "%d", &hours );


    while ( hours != -1 ){
    printf( "Enter hourly rate of the worker ($00.00): " );
    scanf( "%d", &rate );

    if ( hours <= 40 )
    salary = hours * rate;

    else
    salary = ( float ) (hours - 40) * (3/2 * rate) + (40 * rate);

    printf( "Salary is %.2f\n\n\n", salary );
    }


    return 0;
    }

  2. #2
    pancho
    Guest

    Question

    can not understand the reply coz im a begginer.. please can anyone re write the program corrected??

    thanks...the assignment is due tomorrow and i need it desperately...
    thanks again

  3. #3
    pancho
    Guest

    Question sorry...but....it doesnt work either...

    Well, <stdlib.h> is not supposed to appear in my assignment. The program should look like this:

    ----------------------------------------------------------------------
    Enter # of hours of hours worked (-1 to end): 39
    Enter hourly rate of the worker ($00.00): 10.00
    Salary is $390.00



    Enter # of hours of hours worked (-1 to end): 41
    Enter hourly rate of the worker ($00.00): 10.00
    Salary is $415.00



    Enter # of hours of hours worked (-1 to end): -1
    -----------------------------------------------------------------------

    can u correct my program to look like this but with only if/else, while, float statements???

    sorry but im dumb at this

  4. #4
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020
    is this exercise from the deitel book?

  5. #5
    pancho
    Guest

    instructions

    the program instructions are these:
    develop a program that will determine the gross pay for each of several employees. The company pays "straight - time " for the 40 hours worked by each employee and pays "time and a half" for all worked in excess of 40 hours. You are given a list of employees of the company, the number of hours each employee worked last week and the hourly rate of each employee. Your program should input this information for each employee, and should determine and display the employee's gross pay.


    im frustrated becasue i ve been trying to figure out this for 6 hours! my eyes r bleeding!

  6. #6
    pancho
    Guest

    deitel book

    yeeees! it is from that damn book. how can they ask for problems with no examples of them! help me plz....

    i havent even started to do the other one of the palindrome..i dont want even to think about how many hours i will have to spend tonigh doing it.

  7. #7
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020
    actually, palindrome is a pretty easy one once you know it. but it stilled bugged me for a whole day at that moment lol.

    For your problem, just find the hourly rate per hour and the time and a half rate. Minus the num of hours worked by 40 and times the num of hours over 40 by the time-and - and-half rate and then add it to the product of the hours under 40 and the normal hourly rate. Output that. ...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can someome help me with a program please?
    By WinterInChicago in forum C++ Programming
    Replies: 3
    Last Post: 09-21-2006, 11:58 PM
  2. Salary Range Calculator help please!! =(
    By bambino in forum C++ Programming
    Replies: 3
    Last Post: 04-20-2006, 07:17 PM
  3. Help with sample tax program
    By DaMonsta in forum C Programming
    Replies: 1
    Last Post: 05-15-2003, 04:45 AM
  4. finally my salary program but...........
    By pancho in forum C Programming
    Replies: 11
    Last Post: 02-02-2002, 11:28 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 11:04 PM

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