Write a program that gives the user a menu of 8 options. The options are: *Read
ID: 3647072 • Letter: W
Question
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.
include two more menu options that do:
*Sort scores in descending order (use a selection sort algorithm)
&&
*Search for a score (use a binary search algorithm)
*You must store the scores in an array. The size of the array should be declared as a global constant. 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 may use the input file, provided here => numbers.txt 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 numbers.txt when testing your program.
*note, this is a separate task from the previous program
Explanation / Answer
// This program reads data from a file into an array. #include #include using namespace std; int main() { const int ARRAY_SIZE = 10; // Array size int numbers[ARRAY_SIZE]; // Array with 10 elements int count = 0; // Loop counter variable ifstream inputFile; // Input file stream object // Open the file. inputFile.open("TenNumbers.txt"); // Read the numbers from the file into the array. while (count > numbers[count]) count++; // Close the file. inputFile.close(); // Display the numbers read: coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.