Question

I'm having with my C program whenever i insert numbers it keeps outputting zeros here's the...

I'm having with my C program whenever i insert numbers it keeps outputting zeros

here's the code:

#include<stdio.h>

int main(void) {

   int weeklyhours;

   double hourlyrate;

   double grosspay;

   double netpay;

   double federal;

   double state;

   double FICA;

   double Medicare;

   grosspay= weeklyhours * hourlyrate;

   federal = grosspay * 0.1;

   state = grosspay * 0.06;

   FICA = grosspay * 0.062;

   Medicare = grosspay * 0.0145;

   netpay = grosspay - (federal + state + FICA + Medicare);

   printf("Enter the Hours per Week\n");

   scanf("%d", &weeklyhours);

   printf("Enter the Hourly Rate\n");

   scanf("%lf", &hourlyrate);

   printf("Hours per Week: %d\n", weeklyhours);

   printf("Hourly Rate: %f\n", hourlyrate);

   printf("Gross pay: %f\n",grosspay);

   printf("State: %f\n", state);

   printf("FICA: %f\n", FICA);

   printf("Medicare: %f\n", Medicare);

Here's the Output:

  

Enter the Hours per Week

40

Enter the Hourly Rate

8

Hours per Week: 40

Hourly Rate: 8.000000

Gross pay: 0.000000

State: 0.000000

FICA: 0.000000

Medicare: 0.000000

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hey,

Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries

#include<stdio.h>

int main(void) {

int weeklyhours;

double hourlyrate;

double grosspay;

double netpay;

double federal;

double state;

double FICA;

double Medicare;


printf("Enter the Hours per Week ");

scanf("%d", &weeklyhours);

printf("Enter the Hourly Rate ");

scanf("%lf", &hourlyrate);

grosspay= (double)weeklyhours * hourlyrate;

federal = grosspay * 0.1;

state = grosspay * 0.06;

FICA = grosspay * 0.062;

Medicare = grosspay * 0.0145;

netpay = grosspay - (federal + state + FICA + Medicare);

printf("Hours per Week: %d ", weeklyhours);

printf("Hourly Rate: %f ", hourlyrate);

printf("Gross pay: %f ",grosspay);

printf("State: %f ", state);

printf("FICA: %f ", FICA);

printf("Medicare: %f ", Medicare);
return 0;
}

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
I'm having with my C program whenever i insert numbers it keeps outputting zeros here's the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I'm having trouble rounding the numbers i'm getting in my output here's my code: #include<stdio.h> int...

    I'm having trouble rounding the numbers i'm getting in my output here's my code: #include<stdio.h> int main() { char gender; float a1, a2, a3, a4, a5; float waistmeasurement, wristmeasurement, hipmeasurement, forarmmeasurement; float B, bodyweight, Bodyfat, Bodyfatpercentage;    printf("This program determines the body fat of a person.Enter your gender (f|F|m|M): "); scanf("%c", &gender); printf("\n");    if(gender=='F' || gender=='f'){ printf("Enter body weight (in pounds): \n"); scanf("%f", &bodyweight); printf("Enter wrist measurement at fullest point (in inches): \n"); scanf("%f", &wristmeasurement); printf("Enter waist measurement at...

  • So I have a question in regards to my program. I'm learning to program in C...

    So I have a question in regards to my program. I'm learning to program in C and I was curious about the use of functions. We don't get into them in this class but I wanted to see how they work. Here is my program and I would like to create a function for each of my menu options. I created a function to display and read the menu and the option that is entered, but I would like to...

  • Expand the payroll program to combine two sorting techniques (Selection and Exchange sorts) for better efficiency...

    Expand the payroll program to combine two sorting techniques (Selection and Exchange sorts) for better efficiency in sorting the employee’s net pay. //I need to use an EXSEL sort in order to combine the selection and Exchange sorts for my program. I currently have a selection sort in there. Please help me with replacing this with the EXSEL sort. //My input files: //My current code with the sel sort. Please help me replace this with an EXSEL sort. #include <fstream>...

  • i am having trouble displaying results and displaying them evenly it is suppose to look like...

    i am having trouble displaying results and displaying them evenly it is suppose to look like this Enter the following data for employee 1: Employee ID: 1298 Hours worked: 35.8 Pay rate (per hour): 23.45 Enter the following data for employee 2: Employee ID: 1899 Hours worked: 34.5 Pay rate (per hour): 19.5 Enter the following data for employee 3: Employee ID: 4435 Hours worked: 30.5 Pay rate (per hour): 20.75 Enter the following data for employee 4: Employee ID:...

  • I'm having trouble understanding pointers in my c programming class. I posted the pointer assignment below....

    I'm having trouble understanding pointers in my c programming class. I posted the pointer assignment below. If you could leave comments pointing out where pointers are used it would be much appreciated! ----------------------------------------------------------------------------------------------------------------------------------- Write a complete C program for an automatic teller machine that dispenses money. The user should enter the amount desired (a multiple of 10 dollars) and the machine dispenses this amount using the least number of bills. The bills dispenses are 50s, 20s, and 10s. Write a...

  • C++ Program The Ward Bus Manufacturing Company has recently hired you to help them convert their...

    C++ Program The Ward Bus Manufacturing Company has recently hired you to help them convert their manual payroll system to a computer-based system. Write a program to produce a 1-week payroll report for only one employee to serve as a prototype (model) for the administration to review. Input for the system will be the employee’s 4-digit ID number, the employee’s name, hours worked that week, and the employee’s hourly pay rate. Output should consist of the employee’s ID number, the...

  • A) One of the problems that have been discussed in the class is to write a simple C++ program to ...

    C++ programming question will upvote A) One of the problems that have been discussed in the class is to write a simple C++ program to determine the area and circumference of a circle of a given radius. In this lab you will be rewriting the program again but this time you will be writing some functions to take care of the user input and math. Specifically, your main function should look like the following int main //the radius of the...

  • My Java code from last assignment: Previous Java code: public static void main(String args[]) { //...

    My Java code from last assignment: Previous Java code: public static void main(String args[]) { // While loop set-up boolean flag = true; while (flag) { Scanner sc = new Scanner(System.in); // Ask user to enter employee number System.out.print("Enter employee number: "); int employee_number = sc.nextInt(); // Ask user to enter last name System.out.print("Enter employee last name: "); String last_name = sc.next(); // Ask user to enter number of hours worked System.out.print("Enter number of hours worked: "); int hours_worked =...

  • Hey, i was just wondering how i would calculate over time pay in c++ visual studio...

    Hey, i was just wondering how i would calculate over time pay in c++ visual studio 2017? what i have right now is either returning 0 for some reason or being skipped over? im also wondering about the federal tax as well because that also doesn't seem to work, any help is greatly appreciated! these are my variables char chChoice = ' '; int intempID = 0; int intHours = 0; int intOThours = 0; float flOTrate = 0; float...

  • My Java code from last assignment: Previous Java code: public static void main(String args[]) { //...

    My Java code from last assignment: Previous Java code: public static void main(String args[]) { // While loop set-up boolean flag = true; while (flag) { Scanner sc = new Scanner(System.in); // Ask user to enter employee number System.out.print("Enter employee number: "); int employee_number = sc.nextInt(); // Ask user to enter last name System.out.print("Enter employee last name: "); String last_name = sc.next(); // Ask user to enter number of hours worked System.out.print("Enter number of hours worked: "); int hours_worked =...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT