I need help in creating a program to print a receipt

hello,
so I am trying to create a program to print a utility bill receipt. And all the customers information is to be put into an input file with three months charges of water, gas, and electricity. And i am supposed to read all the charges from the file and i have to use a nest for loop some how to calculate it or something along those lines. I am just not sure on how i am supposed to use the loop.

Thank you!
I want to see your codes.
This is not a homework site. We won't do your homework for you. However we are always willing to help solve problems you encountered, correct mistakes you made in your code and answer your questions.

We didn't see your attempts to solve this problem yourself and so we cannot correct mistakes you didn't made and answer questions you didn't ask. To get help you should do something yourself and get real problems with something. If your problem is "I don't understand a thing", then you should go back to basics and study again. As it is impossible to find derivative of function without knowledge in arithmetic, you cannot do more complex tasks in programming without clear understanding of basics
Line 31: There are three parts to a for loop statement. The initialization; the termination condition; and the increment. I only see two parts.

Your termination condition (water+water) doesn't make sense. I see no increment.
If amount is the number of customers, then I would expect your for loop to look like:
1
2
3
4
 
  for (int custnum = 0; custnum < amount; custnum++)
  {  // Do something for each customer
  }


It is unusual to use a for loop when reading from a file. It is more common to read from the file until your read from the file fails.

amount is a poor choice of a variable name for the number of customers. amount usually refers to a dollar amount on a bill.

You haven't specified the format of the input file, so I can't make suggestions about reading the file. Are water, gas, electricity all on the same line? What about customer information?

line 33: the break statement is going to cause you to exit the for loop on the first iteration.

edit: OP has deleted his code.
Last edited on
Topic archived. No new replies allowed.