Home > Back-end >  How to evaluate these code? (from a beginner to add the scholar, is I h 'h' h)
How to evaluate these code? (from a beginner to add the scholar, is I h 'h' h)

Time:10-08

#include
# define H_WAGE1 8.75
# define H_WAGE2 9.33
# define H_WAGE3 10.00
# define H_WAGE4 11.20
# define TIME1 30
# define TIME2 40
# define RATE_T 1.5
# define RATE1 0.15
# define RATE2 0.2
# define RATE3 0.25
# define BREAK1 300
# define BREAK2 450
Int main (void)
{
Total float time, tax,.net, H_WAGE;
Int choice;

Printf (" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n ");
Printf (" Enter the number corresponding to the desired pay rate or action: \ n ");
Printf (" (1) at $8.75/hr (2) $9.33/hr \ n ");
Printf (" (3) at $10.00/hr (4) $11.20/hr \ n ");
Printf (" (5) quit \ n ");
Printf (" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n ");

Printf (" Enter the choice: \ n ");
The scanf (" % d ", & amp; Choice);
If (choice==1 | | choice==2 | | choice==| 3 | choice==4 | | choice==5)
{
The switch (choice)
{
Case 1:
H_WAGE=H_WAGE1;
Printf (" Your choice is 1, $8.75/hr. \ n ");
break;
Case 2:
H_WAGE=H_WAGE2;
Printf (" Your choice is 2, and $9.33/hr. \ n ");
break;
Case 3:
H_WAGE=H_WAGE3;
Printf (" Your choice is 3, $10.00/hr. \ n ");
break;
Case 4:
Printf (" Your choice is 4, $11.20/hr. \ n ");
H_WAGE=H_WAGE4;
break;
Case 5:
Printf (" Your choice is 5, to quit. \ n ");
H_WAGE=0;
break;
Default:
Printf (" Enter the right number. \ n ");
break;

}

}
The else
Printf (" Enter the right number. \ n ");
While (H_WAGE!=0)
{
Printf (" do enter the working time per week: \ n ");

While (the scanf (" % f ", & amp; Time)==1)
{

If (time>=0)
{
If (time<=TIME1)
{
Total=time * H_WAGE;
Tax=total * RATE1;
}
Else if (time{
Total=time * H_WAGE;
Tax=H_WAGE TIME1 * * H_WAGE RATE1 + (time - TIME1) * * RATE2;
}
The else
{
Time=TIME2 + (time - TIME2) * RATE_T;
Total=time * H_WAGE;
If (totalTax=H_WAGE TIME1 * * H_WAGE RATE1 + (time - TIME1) * * RATE2;
The else
Tax=H_WAGE TIME1 * * RATE1 + (BREAK2 - BREAK1) + (total - BREAK2) * * RATE2 RATE3;
}
Net=total - tax;
Printf (" is % 2 f hours, the total income is. % 2 f, the tax is. % 2 f, net income is. % 2 f \ n ", "
, time, total, tax,.net);

}
The else
Printf (" Time always be negtive. \ n ");
Printf (" Enter time again or q to quit. \ n ");
H_WAGE=0;
}
}
Printf (" Done! \n");

return 0;
}

CodePudding user response:

First the if... Else is superfluous, switch statements,

CodePudding user response:

For beginners to learn the first thing is
Write code indentation
Take care of it don't have to discuss how to evaluate the code before
dirty
  • Related