guys

Discussion in 'Programming General' started by PsychicFreak, Jul 11, 2010.

guys
  1. Unread #1 - Jul 11, 2010 at 5:18 PM
  2. PsychicFreak
    Joined:
    Jun 6, 2008
    Posts:
    53
    Referrals:
    0
    Sythe Gold:
    0

    PsychicFreak Member

    guys

    guys how do i make a C program that asks 3 numbers from the user. The 1st value represents hourly pay, second is the number of hours worked and 3rd is the percentage of gross salary. The program multiplies the hourly pay rate by the number of hours worked giving the gross pay. then it multiplies the gross pay by the withholding percentage giving the withholding amount. Subtract withholding amount from the gross pay giving the next pay.


    heres the output
    -gross pay
    -withholding amount
    - net pay

    Data type
    -hourly pay rate (float)
    -no. hours worked (int)
    -percentage (float)

    nid help guys pls
     
  3. Unread #2 - Jul 11, 2010 at 6:55 PM
  4. blindkilla
    Joined:
    Jun 22, 2005
    Posts:
    1,896
    Referrals:
    0
    Sythe Gold:
    6
    Discord Unique ID:
    282000633404456960
    Discord Username:
    sogord

    blindkilla Guru
    $25 USD Donor New

    guys

    This is a very simple program so I am hesitant to post the solution. As a programmer you really need to try and solve problems like these on your own or you won't learn anything. However, I'm hoping you take the time to go through the solution to understand the answer.
    Code:
    #include <stdio.h>
    
    main() {
       float hourlyPay;
       float percentageOfGrossSalary;
       float grossPay;
       float withholdingAmount;
       float nextPay;
       int hoursWorked;
    
        printf("Please enter your hourly pay: ");
             scanf("%f", &hourlyPay);
    
        printf("Please enter the amount of hours you worked: ");
             scanf("%d", &hoursWorked);
       
        printf("Please enter the percentage of gross salary: ");
             scanf("%f", &percentageOfGrossSalary);
    
        grossPay = hoursWorked * hourlyPay;
        withholdingAmount = grossPay * percentageOfGrossSalary;
        nextPay = grossPay - withholdingAmount;
    
    }
    
    There is a quick solution to what you posted. Good luck, and if you have any questions feel free to post :)
     
< Help a beginner out at c | [Charny Coding] Tutorials List [Video] >

Users viewing this thread
1 guest


 
 
Adblock breaks this site