Beyond what i already have, i need really big help please. Write a program that
ID: 3647100 • Letter: B
Question
Beyond what i already have, i need really big help please.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.
-----------------------------------------------------------------------------------------------------
Basically I have this down (with the help of Intro to c++ book) :
// This program reads data from a file into an array.
#include <iostream>
#include <fstream>
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 < ARRAY_SIZE && inputFile >> numbers[count])
count++;
// Close the file.
inputFile.close();
// Display the numbers read:
cout << "The numbers are: ";
for (count = 0; count < ARRAY_SIZE; count++)
cout << numbers[count] << " ";
cout << endl;
return 0;
}
/*
OUTPUT:
The numbers are: 101 102 103 104 105 106 107 108 109 110
*/
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
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.