Yes, sorry this is homework i've been working on this for over a week and am still having major problems. I'm not asking for someone to write this, I already have and will post it below. I need to know what the heck i'm doing wrong. This thing is due tonight and i'm frustrated to the point of tears. I will admit i'm very grateful this is the only programming class I have to take.
Here is the code (hope I don't mess this up too)
Code:#include <stdio.h> #include <stdlib.h> void main(void); { wages (); gasmileage(); decibel(); } void wages(void) { int z; /* initialize variable for program selection */ printf("Enter the number of the program you would like to run\n"); /*determine which program to run*/ printf("1. Calculate Wages \n"); printf("2. Calculate Gas Mileage \n"); printf("3. Evaluate Decibel level \n"); scanf("%d", &z); /*read program selection*/ { if (z=1) int a,b,c,d,e,f; /*initialize variables for wage calculation*/ printf("Please enter employee number\n, a"); /*prompt for wage info*/ printf("Please enter hourly wage\n, b"); printf("Please enter number of hours worked\n, c"); scanf("%lf %lf %lf", &a,&b,&c); /*read wage info*/ if (c>40) /*calculate pay with overtime*/ d=c-40; /*determine amount of overtime*/ e=(c*b)+(d*(b+(b/2))); /*calulate earnings*/ printf("Employee %a whose standard hourly rate of pay is $%b worked %c hours and will be paid $%e\n %lf a, %lf b, %lf c, %lf d"); else /*calculate pay when no overtime*/ f=c*b; printf("Employee %a worked %c hours at a rate of $%b and will be paid %f.\n, &a, &b, &c, &f"); return; /*end of wage*/ } void gasmileage(void) { else if (z=2) int h,i,j,k,l,m,n,p,q; /*initialize variable for gas mileage*/ printf("What is the price of 1 gallon of gas?\n"); /*prompt for gas price*/ scanf("%lf", &k); /*read gas price*/ printf("Do you drive a Mini Cooper? enter 1 for yes 2 for no.\n"); scanf("%d", &l); if (l=1) /*calculate if mini*/ n=k*10; printf("A Mini Cooper will go 510 miles on a tank of gas and each tank will cost $%n when gas is $&k \n, n,k"); else if printf("Do you drive a Neon? enter 1 for yes 2 for no.\n"); scanf("%d", &m); if (m=1) /*calculate if Neon*/ p=k*14; printf("A Neon will go 350 miles on a tank of gas and each tank will cost $%p when gas is $&k \n, p,k"); else if printf("Do you drive an Explorer? enter 1 for yes 2 for no.\n"); scanf("%d", &h); if (h=1) /*calculate if Explorer*/ i=k*30; printf("An Explorer will go 600 miles on a tank of gas and each tank will cost &%i when gas is $&k \n, i,k"); return; /*end of gas mileage*/ } void decibel(void) { else if (z=3) int x; /*initialize variable for decibel level*/ printf("Enter the decibel level at which you listen to your favorite song\n"); scanf("%d", &x); if (x>0 && x<51) printf("&x db is quiet.\n"); else if (x>50 && x<71) printf("&x db is intrusive.\n"); else if (x>70 && x<91) printf("&x db is annoying.\n"); else if (x>90 && x<112) printf("&x db is very annoying.\n"); else if (x>111 && x<141) printf("&x db is uncomfortable.\n"); else (x>140) printf("&x db is damaging.\n"); return; /*end of decibel*/ } else printf("Shame on you, you didn't enter 1, 2 or 3, please try again!\n"); scanf("%d", &z); return; /*end of program*/ }



LinkBack URL
About LinkBacks


