• C

# I am lost - simple calculations

I hav been trying to do this all nite, The program itself runs ok, But when i enter  the over time hours it does not give me an amount. it returns 0.00.
What have i done wrong towars the end of this program as it is only the overtime pay bit that doesnt work.
#include <stdio.h>

void main()
{
float hours,pounds,amount;

printf("\n Please enter the amount of standard hours you worked ");
scanf("%f", &hours);

printf("\n Enter Hourly rate ");
scanf("%f", &pounds);

amount = (float)hours*(float)pounds;
printf("\n Wages for week excluding Over time %.2f pounds \n");

{
float ovrtimrat;
ovrtimrat = (float)1.25*(float)pounds;
printf("\n Over time Rate is %.2f pounds \n");

{
float ovmony,hoursa,ovrtimrat;
printf("\n Enter hours of overtime worked ");
scanf("%f", &hoursa);

ovmony = (float)ovrtimrat*(float)hoursa;
printf("\n Overtime pay is %.2f pounds");

}
}
}

###### Who is Participating?

Commented:
The printf lines where you're attempting to print out a calculated amount, must have a relevant variable passed in:

printf("\n Wages for week excluding Over time %.2f pounds \n",amount);

printf("\n Over time Rate is %.2f pounds \n",ovrtimrat);

printf("\n Overtime pay is %.2f pounds",ovmony);

0

Commented:
#include <stdio.h>

void main()
{
float hours,pounds,amount;
printf("\n Please enter the amount of standard hours you worked ");
scanf("%f", &hours);
printf("\n Enter Hourly rate ");
scanf("%f", &pounds);
amount = (float)hours*(float)pounds;
printf("\n Wages for week excluding Over time %.2f pounds \n", amount);

{
float ovrtimrat;
ovrtimrat = (float)1.25*(float)pounds;
printf("\n Over time Rate is %.2f pounds \n", ovrtimrat);

{
float ovmony,hoursa;
printf("\n Enter hours of overtime worked ");
scanf("%f", &hoursa);
ovmony = (float)ovrtimrat*(float)hoursa;
printf("\n Overtime pay is %.2f pounds\n", ovmony);
}
}
}
0

Commented:
Ignore my comment. It was just 2 minutes too late ;-)
0

Commented:
Did that answer the question pnorris? If so, it is now time to grade the answer.
0

Commented:

If you wish to award multiple experts, just comment here with detail, I'll respond as soon as possible.  As it stands today, you asked the question, got help and not one expert was awarded for the contribution(s) made.  Your response is needed.  I'll monitor through month end, and if you've not returned to complete this, we'll need to decide.  Expert input is welcome (as always) to determine the outcome here if the Asker does not respond.

Your response in finalizing this (and ALL) your question(s) is appreciated.

Moondancer
Community Support Moderator @ Experts Exchange

0

Author Commented:
dam,
I need to take more care with my questions,

Sorry again guys
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.