I've been getting some strange problems with my code so far. You need to input hrs as an integer, rate as a float, and then compute salary as a float. If >40 hrs are eneterd it is time and a half. Make sense? Where am I going wrong? Instructor has not gone over float stuff, so I gathered what I could.
Code:# include <stdio.h> int main() { int hrs; float rate; float salary; while(1){ printf("Enter # of hours worked (-1 to end):"); scanf("%d",&hrs); if(hrs == -1){ return 0; } printf("Enter hourly rate of worker ($00.00):"); scanf("%f",&rate); if(hrs<=40){ salary = rate*hrs; } if(hrs>40){ salary = (rate*40)+((hrs-40)*rate*1.5); } printf("Salary is %.2f \n", salary); } return 0; }



LinkBack URL
About LinkBacks



I was just throwing stuff together to get the overall thing to work and did not pay much attention to detail.
Uppercase is often preferred, simply because when you go to add an 'L' (for a long literal) a lowercase 'l' looks like a numeric 1 (one). (That being said, I usually use a lowercase 'f' myself.)