One thing you must do, is indent your code properly. Now, it looks like a mess with extra braces lurking around here and there. Something like:
#include <stdio.h>
#include <cs50.h>
int main(void)
{
float clip_time;
float real_time;
float pay_rate;
float pay_amt;
float hours;
do
{
printf("Transcription Rates\n");
printf("Clip Time: ");
clip_time = get_float();
}while(clip_time <= 0);
printf("%.2f min clip pays: ", clip_time);
pay_rate = get_float();
printf("So, $%.2f for the project \n", pay_rate * clip_time);
pay_amt = pay_rate * clip_time;
do
{
printf("Time to Complete Clip (in minutes): ");
real_time = get_float();
printf("Equals %.2f hours \n", real_time/60);
hours = real_time/60;
}while(real_time <= 0);
printf("Real time spent per audio minute: %.2f \n", real_time / clip_time);
printf("Hourly pay $%.2f div by %.2f hours equals $%.2f ph \n", pay_amt, hours, pay_amt / hours);
}
Also,
cs50is not a standard header. So, it reduces the portability of your code.You might as well as
return 0;at the end ofmainas it is not implicit in C89 (ansi C)This part:
printf("Equals %.2f hours \n", real_time/60); hours = real_time/60;should be outside the
do...whileloop as it needs to be executed only if the user enters a valid input forreal_time.Using
doubles are better thanfloats because they have much better precision.You could inform the user that invalid input was typed when the user enters some invalid input. But I do not know what
get_floatreturns on non-number inputs. If you do, you can check for it too.