SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Walter Savitch ,kenrick Mock
Chapter:
Streams And File Io
Exercise:
Programming Projects
Question:20 | ISBN:9780132846813 | Edition: 5

Question

Write a class that tracks the five highest scores for a game. The scores should be stored in a file and include the player’s name as a string and the player’s score as an integer. The list of top scores should initially consist of the name Anonymous and scores of 0. The class should support the following functions: ■ A way to output to the screen the name and score of the top five players. The scores should be listed in order, with the highest score first and the lowest score last.

■ A function that takes a new name and score. If the score is higher than any of the top five scores then it should be added to the file and the lowest score discarded. Otherwise, the top list should remain unchanged.

Include an appropriate constructor or destructor if necessary, along with any helper functions. Write a main function that tests your class by simulating several score entries and outputting the high score list.


TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Sorry the answer is not available at the moment…

If you are able to find the answer, please make sure to post it here. So that your Juniors have smile on their lips and feel happy.

Spread the 'tradition of sharing'.