Thursday, July 9, 2009

I need help using the if statement in my C program?

hey i need to put if and else statement into this program....#include%26lt;stdio.h%26gt;





int main()


{


float a, b, c;


printf(" *** WAGE CALCULATOR ***\n\n\n");


scanf("c");





printf("How many hours have you worked this week? Hit enter\n");


scanf("%f",%26amp;a);





printf("what is your hourly rate? Hit enter\n");


scanf("%f",%26amp;b);





c=a*b;


printf("your gross salary is: $%f\n",c);


getc(stdin);


return 0;


}


i need two if statements.i need one to follow ....printf("How many hours have you worked this week? Hit enter\n");


scanf("%f",%26amp;a); ....when someone types in a value over 40 it has to say "ERROR value over 40 not accepted" and if under 40 the program needs to continue.





my second if statement needs to follow.....printf("what is your hourly rate? Hit enter\n");


scanf("%f",%26amp;b);...............and if the value is less then 6.75 it has to say"ERROR value under minimum wage not accepted" and if over 6.75 program needs to continue. email me if u need more info. thanks alot

I need help using the if statement in my C program?
I didn't compile this, but it should be pretty close. The "else" statement does not need to be explicitly defined in this case. It is implied.





#include%26lt;stdio.h%26gt;





int main()


{


float a, b, c;


printf(" *** WAGE CALCULATOR ***\n\n\n");


scanf("c");





printf("How many hours have you worked this week? Hit enter\n");


scanf("%f",%26amp;a);





if (a %26gt; 40) {


printf("ERROR value over 40 not accepted\n");


return 1;


}





printf("what is your hourly rate? Hit enter\n");


scanf("%f",%26amp;b);





if (b %26lt; 6.75) {


printf("ERROR value under minimum wage not accepted\n");


return 1;


}





c=a*b;


printf("your gross salary is: $%f\n",c);


getc(stdin);


return 0;


}
Reply:so


if(a %26gt; 40)


{


printf("Sorry we don't believe people actually work without clock watching");


return;


}





and


if(b %26lt; 6.75)


{


printf("Sorry we think all employers are responsible and respect the law you mus be some crazy illegal immigrant, we will not help you);


return;


}





i guess the returns will help you.


No comments:

Post a Comment