#include <stdio.h>
int main()
{
float salary;
int rate, hours;
rate = 0;
hours = 0;
printf( "Enter # of hours worked (-1 to end): " );
scanf( "%d", &hours );
while ( hours != -1 ){
printf( "Enter hourly rate of the worker ($00.00): " );
scanf( "%d", &rate );
if ( hours <= 40 )
salary = hours * rate;
if ( hours > 40 )
salary = ( float ) (hours - 40) * (1.50 * rate) + (40 * rate);
printf( "Salary is $%.2f\n\n\n", salary );
printf( "Enter # of hours worked (-1 to end): " );
scanf( "%d", &hours );
}
return 0;
}
Almost done guys!!! i just want to know how to input decimal values like 9.56 in the rate field without causing a infinite loop...thaaaaanks!