.Txt file calculator?

Jul 31, 2016 at 4:02pm
Hi,

I am currently working on one of my first programmes.

It is to do with a Shop. I am having a hard time figuring out how to add the transactions of the customer (saves with I/Ostream) to display to the manager. I need the Litre Amount and Payment Total. I am looking to have 2 final sums of the Total Litre Amount and Total payment amount.

below is what is displayed in the text file.
I hope you're able to help.

Thanks.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  Customer Pump Number: 2
Customer Petrol Type: 1.040000
Customer Litre Amount: 30.000000
Customer Payment Total: 31.199999
 
 
 
Customer Pump Number: 1
Customer Petrol Type: 1.040000
Customer Litre Amount: 44.000000
Customer Payment Total: 45.759998
 
 
 
Customer Pump Number: 3
Customer Petrol Type: 1.040000
Customer Litre Amount: 22.000000
Customer Payment Total: 22.879999
 
 
 
Customer Pump Number: 2
Customer Petrol Type: 1.040000
Customer Litre Amount: 4.000000
Customer Payment Total: 4.160000
Jul 31, 2016 at 5:52pm
The job is not soo easy. You would need to create a struct or class to hold the data, read the data from the file and store it in a vector. Then you can do all kinds of calculations.
Do you have experience with files and vectors?
Jul 31, 2016 at 6:07pm
I don't have much experience at all, I'll need all the help i can get.
Jul 31, 2016 at 7:24pm
Maybe best to start learning about files.
http://www.cplusplus.com/doc/tutorial/files/
Jul 31, 2016 at 7:43pm
I have read that article it doesn't explain my problem though.
Jul 31, 2016 at 8:29pm
First you need to learn to read the file line by line.
Once you have done this then you can focus on the second step - extracting the number from the line.
Topic archived. No new replies allowed.