-
Language
C
-
Description
A code that calculates the following:
First 50 units - $0.153/units used
Second 50 units - $0.439/units used
Excess units - $0.838/units used
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdio.h>
#include <stdlib.h>
int main (void)
{
float amount, units;
printf ("Enter the value of units: ");
scanf ("%f", &units);
(void) getchar ();
amount=0;
if(units<50)
amount=units*0.153;
if(units>=50&&units<100)
amount=50.0*0.153+(units-50)*0.439;
if(units>=100)
amount=50.0*0.153+50.0*0.439+(units-100)*0.838;
printf ("Value of amount: %g\n", amount);
putchar ('\n');
system ("pause");
return EXIT_SUCCESS;
}
#include <stdlib.h>
int main (void)
{
float amount, units;
printf ("Enter the value of units: ");
scanf ("%f", &units);
(void) getchar ();
amount=0;
if(units<50)
amount=units*0.153;
if(units>=50&&units<100)
amount=50.0*0.153+(units-50)*0.439;
if(units>=100)
amount=50.0*0.153+50.0*0.439+(units-100)*0.838;
printf ("Value of amount: %g\n", amount);
putchar ('\n');
system ("pause");
return EXIT_SUCCESS;
}