subject

Write a program that reads a sequence of scores from a file and outputs the highest score. File name is input by the user (using cin >>) The program uses a function getHighscore() to read the input from file and determine the highest score. This function may throw two exceptions (depending on the situations):

FileIOError, if the file can not be opened
EmptyFileError, if the file includes no scores
Both exceptions must be defined as separate classes. These two classes can be empty or inherit from existing exception class, like run_time error class.

You can assume that, if a file includes scores, they are all positive integers and separated by spaces.

input1.txt is empty

input4.txt: 30 23 14 28 41

main. cpp

#include
#include
#include

using namespace std;

//Add exception classes

//Define getHighscore function

int main()
{
string filename;
cin >> filename;

try
{
int highscore = getHighscore(filename);
cout << "The high score is " << highscore << endl;
}
catch(/*catch FileIOError*/)
{
cout << "Could not open the scores file.\n";
}
catch(/*catch EmptyFileError*/)
{
cout << "The file is empty.\n";
}
return 0;
}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 15:30
In a compound condition, both conditions on either side of the logical operator and must be true for the overall condition to be true. a: true b: false
Answers: 1
question
Computers and Technology, 22.06.2019 21:00
Kirk found a local community college with a two-year program and he is comparing the cost with that of an out-of-state two-year school. what is the expected total cost for one year at the local community college if kirk lives at home? what is the expected total cost for one year at the out-of-state school if kirk lives on campus?
Answers: 2
question
Computers and Technology, 23.06.2019 02:00
Which software would you use to create a print design? a. illustrator b. audacity c. reaper d. dreamweaver
Answers: 2
question
Computers and Technology, 23.06.2019 04:00
Write a method that takes in an array of point2d objects, and then analyzes the dataset to find points that are close together. be sure to review the point2d api. in your method, if the distance between any pair of points is less than 10, display the distance and the (x,y)s of each point. for example, "the distance between (3,5) and (8,9) is 6.40312." the complete api for the point2d adt may be viewed at ~pf/sedgewick-wayne/algs4/documentation/point2d.html (links to an external site.)links to an external site.. try to write your program directly from the api - do not review the adt's source code.
Answers: 1
You know the right answer?
Write a program that reads a sequence of scores from a file and outputs the highest score. File name...
Questions
question
English, 18.07.2019 10:30
question
Biology, 18.07.2019 10:30
question
Health, 18.07.2019 10:30
Questions on the website: 13722363