Consider a file named transaction.txt which contains unknown number of lines. Each line contains data of one transaction as follows: username (string), amount (float), and membership number (int). Write a C++ program that reads the data from the file, then displays on screen the number of users, the total amount, the average of amounts, the lowest amount and the highest amount. Reading from the file should stop when one or more of the conditions given below becomes true: (a) The end of file has been reached. (b) The “user999” is reached. transaction.txt Hassan 12.5 12345 Mariam 5.2 87542 Zahra 33.1 93568 :: :: :: Sample Screen Output Number of users: 54 Transactions total amount: 2658.7 The average of amounts: 120 The highest amount: 280 The lowest amount: 5.2
Consider a file named transaction.txt which contains unknown number of lines. Each line contains data of one transaction as follows: username (string), amount (float), and membership number (int). Write a C++
(a) The end of file has been reached. (b) The “user999” is reached.
transaction.txt
Hassan 12.5 12345 Mariam 5.2 87542 Zahra 33.1 93568 ::
:: ::
Sample Screen Output
Number of users: 54 Transactions total amount: 2658.7 The average of amounts: 120 The highest amount: 280 The lowest amount: 5.2
Step by step
Solved in 3 steps with 2 images