[SOLVED] CS150 Lab 12

35.00 $

Programming resource
Digital learning resource
Category:
✓ Practical programming resource
✓ Suitable for guided study and reference
✓ Tutor guidance available when needed

Description

5/5 - (2 votes)

Have the user input a filename to read in ints from. Print each to the screen, one per line and keep a running total.
Print the total at the end. If the file does not exist say so and do not print the total.
Test Case 1:
File contents (ask user to enter filename, the file they enter contains this): 2 4 6 8 10
Sample output:
Read 2 from file. Read 4 from file.
Read 6 from file.
Read 8 from file.
Read 10 from file.
Total is 30.
Test Case 2:
File contents (ask user to enter filename, the file they enter contains this):
1
3
5
7
Sample Output:
Read 1 from file.
Read 3 from file.
Read 5 from file.
Read 7 from file.
Total is 16.
Test Case 3:
(nonexistent file – user enters nonexistent filename)
Sample output:
Failed to open file.

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.