,

[SOLVED] Cs150 – lab 12

$25

File Name: Cs150_____lab_12.zip
File Size: 150.72 KB

Categories: , Tags: ,
5/5 - (1 vote)

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.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] Cs150 – lab 12[SOLVED] Cs150 – lab 12
$25