Sample Output
Return to assignment description
There are four examples of the program being run below.
-
countryData.txt
This is the first file to test your program with.
It contains only valid information.
-
wonkyData.txt
The second file to test your program with.
It contains multiple examples of bad data.
-
Third time lucky
The user enters a valid file name on the third try.
-
Three strikes, you're out
The user fails to enter a valid file name within three tries.
Return to assignment description
Correct Data File
Country Report
--------------
This program reads country data from a file and prints a report.
by Mark Young (A00000000)
Enter file name: countryData.txt↩
Country Population Area (km^2) Density (/km^2)
------- ---------- ----------- ---------------
Austria 8,474,000 83,855 101.06
Brazil 200,400,000 8,514,215 23.54
Canada 35,160,000 9,984,670 3.52
Japan 127,300,000 377,944 336.82
Singapore 5,399,000 719 7508.00
Vatican City 842 0 1913.64
Zambia 14,540,000 752,614 19.32
Return to top
Data File with Many Problems
Country Report
--------------
This program reads country data from a file and prints a report.
by Mark Young (A00000000)
Enter file name: wonkyData.txt↩
Error reading data for Non-numeric Population
Skipping corrupt country data.
Error reading data for Non-numeric Area
Skipping corrupt country data.
Error reading data for Negative Population
Inappropriate population or area: Illegal population: -1.
Error reading data for Negative Area
Inappropriate population or area: Illegal area: : -0.1.
Error reading data for Incomplete Data
Unexpected end-of-file.
Country Population Area (km^2) Density (/km^2)
------- ---------- ----------- ---------------
Canada 35,160,000 9,985,000 3.52
Austria 8,474,000 83,855 101.06
Japan 127,300,000 377,944 336.82
Brazil 200,400,000 8,516,000 23.53
Zambia 14,540,000 752,614 19.32
Vatican City 842 0 1913.64
Singapore 5,399,000 719 7508.00
Return to top
User enters a valid file name on the third attempt
Country Report
--------------
This program reads country data from a file and prints a report.
by Mark Young (A00000000)
Enter file name: noSuch.txt↩
I can't find that file!
Enter file name: wonkyData↩
I can't find that file!
Enter file name: countryData.txt↩
Country Population Area (km^2) Density (/km^2)
------- ---------- ----------- ---------------
Austria 8,474,000 83,855 101.06
Brazil 200,400,000 8,514,215 23.54
Canada 35,160,000 9,984,670 3.52
Japan 127,300,000 377,944 336.82
Singapore 5,399,000 719 7508.00
Vatican City 842 0 1913.64
Zambia 14,540,000 752,614 19.32
Return to top
User fails to enter a valid file name in three attamepts
Country Report
--------------
This program reads country data from a file and prints a report.
by Mark Young (A00000000)
Enter file name: not this line↩
I can't find that file!
Enter file name: not this line, either↩
I can't find that file!
Enter file name: for sure not this line↩
I can't find that file!
Too many failures.
Quitting.
Return to top
Return to
Return to assignment description