Preparing for midterm exam

Here is another question which I am stuck with. Can't find the way to
set it up using <stdio.h> . Greatful for the support I can get.

Greetings Neo
--------------

Input the number of user and the electricity usage(unit) each day and show the payment of electricity by using below table (Enter -1 when asking to enter the number of customer to end the program)

First 150 units cost 1.5 dollars per unit
151 – 400 units cost 1.85 dollars per unit
exceed 401 units cost 1.98 dollars per unit

Example:
To calculate
if electricity usage is 600 units so
150 * 1.5 = …. 1.
250 * 1.85 = … 2.
200 * 1.98 = … 3.
FT vax (units * 0.9) so 600 * 0.9 = ….4
total = 1.+2.+3.+4. = t.

vat 7 % = t. * (7/100) = v.
GRAND total = t.+v.

Example
Enter -1 when asking to enter the number of customer to end the program /*show the total of customers and received money*/

Enter the number of customer : 1
Enter the usage unit : 500
The charge of usage units is ………

Enter the number of customer : 0
Enter the number of customer:5
Enter the number of customer : 2
Enter the usage unit : 2000
The charge of usage units is ………..

Enter the number of customer: -50
Enter the number of customer : -10
Enter the number of customer : -1

The total number of customer is 2
The total charge of usage units is ……………
This is not a question. This is your assignment. No point to asking for someone to do it for you.

Do you have any specific question? Have you done something so far?

It would make some sense to ask something when you are stuck but you have tried something before yourself.

Please read:
http://www.cplusplus.com/forum/beginner/1/
regarding this question...I had some trouble to complete it. This is what I have done so far...appreciate the help...

#include <math.h>

int main()
{
int n=0, count=1;
float x, totalcost=0, total, ftvax, grandtotal, vat7, cost;

while(n!=-1)
{
printf("Enter the number of customer (-1 to exit) :");
scanf("%d", &n);

if(n==count)
{
printf("Enter the usage unit :");
scanf("%f", &x);

//dont know how to add the if with these conditions...

First 150 units cost 1.5 dollars per unit
151 – 400 units cost 1.85 dollars per unit
exceed 401 units cost 1.98 dollars per unit



}
ftvax = x * 0.9;
total = cost + ftvax;
vat7 = total * 0.07;
grandtotal = total + vat7;
totalcost = totalcost + grandtotal;
count++;

printf("The charge of usage units is %.2f\n", grandtotal);
}
}
printf("The total number of customer is %d\n", count);
printf("The total charge of usage units is %.2f\n", totalcost);

return 0;
}






Please ... Some tag please.
It's killing me reading these post all over the place.
These conditions are pretty simple. Just take the user input, and check it against these ranges, then compute the cost per input. Stick all this in a while and your set.

Also, after scanning through this a little bit, I don't think that if is set up right. With how it is, unless I type in 1 for how many users, that condition is never met. Granted on my phone so I can't really examine this well or test it. But it looks wrong.
Topic archived. No new replies allowed.