• Log in or sign up for an account here: https://www.sythe.org/login

guys

PsychicFreak

Member
Joined
Jun 6, 2008
Sythe Gold
0
Messages
53
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
 
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

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 :)
 
Runescape Gamblingrunescape gambling
Back
Top