Question: why aren't the if and else if staments working in my C program the only thing that is showing up is the else statement? /

why aren't the if and else if staments working in my C program the only thing that is showing up is the else statement?
// SuperCalcV2.c by Sarah Place 9/22/24
#include
int main(void)
{
printf("Jayhawk Supercomputer Usage Calculator by Sarah Place");
int hoursUsed=0, minutesUsed=0, secondsUsed=0;
printf("Enter hours used as a whole number (0-100)");
scanf("%d",&hoursUsed);
printf("Enter minutes used as a whole number (0-59)");
scanf("%d",&minutesUsed);
printf("Enter seconds used as a whole number (0-59)");
scanf("%d",&secondsUsed);
int totalSeconds = hoursUsed *3600+ minutesUsed *60+ secondsUsed;
printf("Total Seconds of Usage =%d",totalSeconds);
float totalHours =(float)hoursUsed +(float)minutesUsed/60+(float)secondsUsed/3600;
printf("Total Hours of Usage =%3.4f",totalHours);
float totalDays =(float)hoursUsed/24+(float)minutesUsed/1440+(float)secondsUsed/86400;
printf("Total Days of Usage =%3.4f",totalDays);
float rate =0.0f;
if (totalSeconds <=3000){
rate =0.67f;
}
else if (totalSeconds <=6000){
rate =0.57f;
}
else if (totalSeconds <=9000){
rate =0.47f;
}
else if (totalSeconds <=36000){
rate =0.37f;
}
else{
rate =0.27f;
}
printf("Rate Per Second =%.2f",rate);
printf("Thanks for Using Jayhawk Supercomputer!");
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!