Computers and Technology, 19.08.2020 23:01 gabrielar80
Modify your program from Exercise 1 so that it reads the information from the gradfile. txt file, reading until the end of file is encountered. You will need to first retrieve this file from the Lab 7 folder and place it in the same folder as your C++ source code. Run the program.// This program will read in a group of test scores (positive integers from 1 to 100)// from the keyboard and then calculate and output the average score// as well as the highest and lowest score. There will be a maximum of 100 scores.//#include#include#includeus ing namespace std;typedef int GradeType[100]; // declares a new data type:// an integer array of 100 elementsfloat findAverage(const GradeType, int); // finds average of all gradesint findHighest(const GradeType, int); // finds highest of all gradesint findLowest(const GradeType, int); // finds lowest of all gradesint main(){GradeType grades; // the array holding the grades. int numberOfGrades; // the number of grades read. int pos; // index to the array. float avgOfGrades; // contains the average of the grades. int highestGrade; // contains the highest grade. int lowestGrade; // contains the lowest grade. fstream dataFile;dataFile. open("gradfile. txt", ios::out | ios::app | ios::binary);if (!dataFile){cout << "Error: Can't open the file named gradfile. txt.\n";exit(1);}// Read in the values into the arraypos = 0;dataFile >> grades[pos];while (grades[pos] != -99){pos++;dataFile >> grades[pos];}numberOfGrades = pos;// call to the function to find averageavgOfGrades = findAverage(grades, numberOfGrades);cout << endl << "The average of all the grades is " << avgOfGrades << endl;highestGrade = findHighest(grades, numberOfGrades);cout << endl << "The highest grade is " << highestGrade << endl;lowestGrade = findLowest(grades, numberOfGrades);cout << "The lowest grade is " << lowestGrade << endl;system("pause");return 0;} findAverage task: This function receives an array of integers and its size.// It finds and returns the average of the numbers in the array// data in: array of floating point numbers// data returned: avarage of the numbers in the arrayfloat findAverage(const GradeType array, int size){float sum = 0; // holds the sum of all the numbersfor (int pos = 0; pos < size; pos++)sum = sum + array[pos];return (sum / size); //returns the average} findHighest task: This function receives an array of integers and its size.// It finds and returns the highest value of the numbers in// the array// data in: array of floating point numbers// data returned: highest value of the numbers in the arrayint findHighest(const GradeType array, int size){int highestgrade = array[0];for (int pos = 0; pos < size; pos++)if (array[pos] > highestgrade){highestgrade = array[pos];}return highestgrade;} findLowest task: This function receives an array of integers and its size.// It finds and returns the lowest value of the numbers in// the array// data in: array of floating point numbers// data returned: lowest value of the numbers in the arrayint findLowest(const GradeType array, int size){int lowestgrade = array[0];for (int pos = 0; pos > size; pos++)if (array[pos] < lowestgrade){lowestgrade = array[pos];}return lowestgrade;}Please run your code before answer, When I run this on UNIX it showed Segmentation fault (core dumped).
Answers: 3
Computers and Technology, 22.06.2019 02:30, capo9972
Write a program that takes in 3 inputs [players (int type), expected game time (double type), team (char type)] and calculates actual game time (double) based on the following conditions: if the number of players or the expected game time is less than or equal to zero, it should output wrong input if the number of players is greater than 0 and less than or equal to 6 and if they are on the â€r’ or â€r’ team, their game time will be 10% faster. and if they are on the â€b’ or â€b’ team, their game time will be 15% faster. and if they are on the â€y’ or â€y’ team, their game time will be 20% faster. and if they are on any other team, they will play 0% faster. if the number of players is greater than 6 but less than or equal to 12 and if they are on the â€r’ or â€r’ team, their game time will be 20% faster. and if they are on the â€b’ or â€b’ team, their game time will be 25% faster. and if they are on the â€y’ or â€y’ team their game time will be 30% faster. and if they are on any other team, they will play 0% faster. if the number of players is greater than 12 but less than or equal to 18 and if they are on the â€r’ or â€r’ team, their game time will be 30% faster. and if they are on the â€b’ or â€b’ team, their game time will be 35% faster. and if they are on the â€y’ or â€y’ team, their game time will
Answers: 2
Computers and Technology, 22.06.2019 19:20, mayaparness
Write a program that prompts the user to input a string. the program then uses the function substr to remove all the vowels from the string. for example, if str = "there", then after removing all the vowels, str = "thr". after removing all the vowels, output the string. your program must contain a function to remove all the vowels and a function to determine whether a character is a vowel.
Answers: 2
Computers and Technology, 23.06.2019 06:30, eddsworldfrantic
You have a small company and want to keep your costs low, but it is important your employees share data. which network would provide you with the most economical solution?
Answers: 1
Modify your program from Exercise 1 so that it reads the information from the gradfile. txt file, re...
Engineering, 23.08.2019 16:10
Mathematics, 23.08.2019 16:10