Computer Science 121 – Fall 2016 Program #4 – Due Tuesday, 9/20 by 11:50 am on Titanium (also submit printout) Write a C++ program that will: Ask the user for the name of an input file. Read in this name and open that text file for input. Ask the user which of two options they want to do: Read in student data Count lines and characters Read in the user’s response, and perform the specified operation. Specifically, if the user chooses the student data option, For each student record,

read in the student name (a string), read in the number of scores for that student (an int) read in all of the scores for that student, adding them into a total as they are found (doubles). Calculate the average score for that student (double). Write out the student name, the number of scores, and the average score for that student.

Repeat until no more student records are found. If the user chooses the lines and characters option, Read in each line of the file If a line contains some text (is non-empty), then count that line and

find the number of characters that the line contains. Continue until no more lines of text are found in the file. Write out the total number of lines that contained text and the Average number of characters that were found per line. Sample Runs: Please enter a file name: input1.txt 1 Read student data 2 Count characters Please choose one: 1 Joe Smith has 6 scores with an average of 22.2333 Sue Ann Quigley has 4 scores with an average of 21.825 Terry Thompson has 3 scores with an average of 22.4667 ------ Please enter a file name: input1.txt 1 Read student data 2 Count characters Please choose one: 2 There were 19 lines containing text with an average of 4.68421 characters per line The usual comments are required. Submit printout and on Titanium.

Get help from top-rated tutors in any subject.

Efficiently complete your homework and academic assignments by getting help from the experts at homeworkarchive.com