Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using any standard C++ compiler write your program (aka. source) code, compile and debug your program until you show the correct program output. Submit your

Using any standard C++ compiler write your program (aka. source) code, compile and debug your program until you show the correct program output. Submit your "source code" to the programming question below by saving it as a .cpp file and attaching it to the file submission area below.

Name your file as follows: LastName_p4.cpp

Project 4: 1-D array processing: Score Analysis program

Write a program that gives the user a menu of 8 options. The options are:

Read in 10 scores (integers) from the user.

Read in 10 scores from a file, scores.txt.

Print the 10 scores.

Print the highest score.

Print the lowest score.

Print the mean (average) of the 10 scores.

Print a score based on an entry or row# and show how many scores are higher.

Exit the program.

Both the size of the array (a constant) and the array itself must be declared locally inside of int main(). You should initialize the array to some value (probably 0) in case the user chooses options 3 - 7 before 1 or 2. Options 1 or 2 will overwrite any value previously stored in the array.

Each option in the menu must simply call a function. Each function must at minimum pass in the array and the size of the array. You must list all function prototypes above int main () and all function definitions must appear after int main(). You will find a few helpful programs in Gaddis text - Chapter 8 that provide examples on how to declare and process homogenous data with 1-D arrays as well as the set-up of some useful array functions.

You may use the input file, provided here => scores.txtimage text in transcribed or you may create your own. You do not need to turn in your input file. Please note that I will be using this version of the scores.txt when testing your program.

Provide appropriate input validation where necessary, use meaningful identifier names and DO NOT declare any variables globally.

Here is a sample run of the program that you may use as a guide in helping set-up the interface and also provides a few check figures...

 --------------------------------------------------- 1-D ARRAY PROCESSING MENU OPTIONS --------------------------------------------------- 1. Read in 10 scores from user. 2. Read in 10 scores from the file, scores.txt. 3. Print all scores. 4. Print the highest score. 5. Print the lowest score. 6. Print the average score. 7. Print one score (give its entry number) 8. Quit program Enter your choice:1 Enter score #1: 56 Enter score #2: 89 Enter score #3: 78 Enter score #4: 66 Enter score #5: 72 Enter score #6: 99 Enter score #7: 95 Enter score #8: 100 Enter score #9: 85 Enter score #10: 68 --------------------------------------------------- 1-D ARRAY PROCESSING MENU OPTIONS --------------------------------------------------- 1. Read in 10 scores from user. 2. Read in 10 scores from the file, scores.txt. 3. Print all scores. 4. Print the highest score. 5. Print the lowest score. 6. Print the average score. 7. Print one score (give its entry number) 8. Quit program Enter your choice:4 The highest score is 100 --------------------------------------------------- 1-D ARRAY PROCESSING MENU OPTIONS --------------------------------------------------- 1. Read in 10 scores from user. 2. Read in 10 scores from the file, scores.txt. 3. Print all scores. 4. Print the highest score. 5. Print the lowest score. 6. Print the average score. 7. Print one score (give its entry number) 8. Quit program Enter your choice:5 The lowest score is 56 --------------------------------------------------- 1-D ARRAY PROCESSING MENU OPTIONS --------------------------------------------------- 1. Read in 10 scores from user. 2. Read in 10 scores from the file, scores.txt. 3. Print all scores. 4. Print the highest score. 5. Print the lowest score. 6. Print the average score. 7. Print one score (give its entry number) 8. Quit program Enter your choice:6 The average score is 80.80 --------------------------------------------------- 1-D ARRAY PROCESSING MENU OPTIONS --------------------------------------------------- 1. Read in 10 scores from user. 2. Read in 10 scores from the file, scores.txt. 3. Print all scores. 4. Print the highest score. 5. Print the lowest score. 6. Print the average score. 7. Print one score (give its entry number) 8. Quit program Enter your choice:2 Please enter filename:scores.txt File has successfully opened and 10 scores have been read and stored. Please select the print all scores menu option to view the scores --------------------------------------------------- 1-D ARRAY PROCESSING MENU OPTIONS --------------------------------------------------- 1. Read in 10 scores from user. 2. Read in 10 scores from the file, scores.txt. 3. Print all scores. 4. Print the highest score. 5. Print the lowest score. 6. Print the average score. 7. Print one score (give its entry number) 8. Quit program Enter your choice:3 score #1: 47 score #2: 89 score #3: 65 score #4: 55 score #5: 62 score #6: 95 score #7: 87 score #8: 75 score #9: 100 score #10: 79 --------------------------------------------------- 1-D ARRAY PROCESSING MENU OPTIONS --------------------------------------------------- 1. Read in 10 scores from user. 2. Read in 10 scores from the file, scores.txt. 3. Print all scores. 4. Print the highest score. 5. Print the lowest score. 6. Print the average score. 7. Print one score (give its entry number) 8. Quit program Enter your choice:7 Please enter entry or row # of score you want:7 Entry #7 score:87 Score statistics:3 higher --------------------------------------------------- 1-D ARRAY PROCESSING MENU OPTIONS --------------------------------------------------- 1. Read in 10 scores from user. 2. Read in 10 scores from the file, scores.txt. 3. Print all scores. 4. Print the highest score. 5. Print the lowest score. 6. Print the average score. 7. Print one score (give its entry number) 8. Quit program Enter your choice:9 INVALID CHOICE ...please retype --------------------------------------------------- 1-D ARRAY PROCESSING MENU OPTIONS --------------------------------------------------- 1. Read in 10 scores from user. 2. Read in 10 scores from the file, scores.txt. 3. Print all scores. 4. Print the highest score. 5. Print the lowest score. 6. Print the average score. 7. Print one score (give its entry number) 8. Quit program Enter your choice:8 Array processing test now concluded. Exiting program ..... Process returned 0 (0x0) execution time : 128.997 s Press any key to continue.

If your program does not compile, it will not be graded. HINT: I am thinking seven to eight array processing functions with procedures or algorithms that address the menu choice should be adequate. Use a do while loop with a switch statement. You should call the relevant functions from each case. Compile your code often. Only write a small portion of code, let's say a single function for a specific menu option, check that it still compiles before moving on. This way when you get a syntax error, you can be fairly certain the error is in the part you just wrote.

EXTRA CREDIT (15points) - Applies only if programming segment (i.e., menu options 1-8) above is successfully completed.

Modify the program that you wrote above "Score Analysis" so it includes two more menu options and write the necessary procedures specified below in two additional functions:

9. Use a selection sort algorithm (see Gaddis textbook Section 9.3 pgs 613 - 621 or review the selection sort example in section 10.6 of the Lesson notes for weeks 15 -16) to sort scores in descending order. (7 points)

10. Use a binary search algorithm (see Gaddis textbook Section 9.1 pgs. 603 - 609) to allow the user to search for a score. Display appropriate messages such as "Score of 80 was found" or "Score of 80 was not found". (8 points)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Google Analytics 4 The Data Driven Marketing Revolution

Authors: Galen Poll

2024th Edition

B0CRK92F5F, 979-8873956234

More Books

Students also viewed these Databases questions

Question

Distinguish between intrapersonal and interpersonal mindfulness.

Answered: 1 week ago

Question

3. Contrast relational contexts in organizations

Answered: 1 week ago

Question

2. Describe ways in which organizational culture is communicated

Answered: 1 week ago

Question

1. Describe and compare approaches to managing an organization

Answered: 1 week ago