For this assignment, you are to write a program that does the following: (C++)
• read exam scores from a file name data.txt into an array, and
• after reading all the scores, output the following to the monitor: the average score and the total number of scores.
In addition, the program must use the following functions:
//precondition: fileName is name of the file to open, inFile is the input file 2 of 2
//postcondition: inFile is opened. If inFile cannot be opened, a message is
// written to cout and the program exits void openFile(string filename, ifstream& inFile);
//precondition: a score array, size is a’s length //postcondition:avg contains score score average float calculateAverage(float a, int size) Remember to perform all required operations on the files, otherwise you receive a significant deduction. Failure to conform to the specification will result in significant deductions (up to 50 points).
Finally, every function must be commented with preconditions and post conditions. Failure to include these things will result in a 20 point deduction. Each line of the data file will contain a score. You can assume that each non-empty line in the file contains a score and nothing else. You can assume that there will be no more than 25 scores in the file, but there may be any number from two to 25.
#include<iostream>
#include<fstream>
#include<cstdlib>
using namespace std;
float calculateAverage(float a, int size)
{
return a/size;
}
void openFile(string filename, ifstream& inFile)
{
inFile.open(filename);
if(!inFile)
{
cout<<"Unable to open the
file exiting the prgram."<<endl;
exit(0);
}
float scores[25],sum=0;
int count=0;
while(inFile>>scores[count])
{
sum+=scores[count];
count++;
}
cout<<"Sum of all the score grade is
:"<<sum<<endl;
cout<<"Avrage of the score is :
"<<calculateAverage(sum,count)<<endl<<endl;
}
int main()
{
ifstream inFile;
openFile("grades.txt",inFile);
return 1;
}
output

grades.txt

If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.
For this assignment, you are to write a program that does the following: (C++) • read exam scores...
For this assignment, you are to write a program that does the following: • read exam scores from a file name data.txt into an array, and • after reading all the scores, output the following to the monitor: the average score and the total number of scores. In addition, the program must use the following functions: //precondition: fileName is name of the file to open, inFile is the input file 2 of 2 //postcondition: inFile is opened. If inFile cannot...
For this assignment, you are to write a program that does the following: read temperatures from a file name data.txt into an array, and after reading all the temperatures, output the following to the monitor: the average temperature, the minimum temperature, and the total number of temperatures read. In addition, the program must use the following functions: //precondition: fileName is name of the file to open, inFile is the input file //postcondition: inFile is opened. If inFile cannot...
// 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 <iostream> using namespace std; float findAverage (const int[], int); // finds average of all grades int findHighest (const int[], int); // finds highest of all grades int findLowest (const int[], int); //...
Microsoft Visual Studios 2017 Write a C++ program that computes a student’s grade for an assignment as a percentage given the student’s score and total points. The final score must be rounded up to the nearest whole value using the ceil function in the <cmath> header file. You must also display the floating-point result up to 5 decimal places. The input to the program must come from a file containing a single line with the score and total separated by...
The following program is in c++ ; I am trying to read in games from a file and when doing so I am only reading in parts of the file. It is giving me a segmentation fault error I am going to post my code below if anyone is able to help me debug the program I would greatly appreciate it. The program is too large to be submitted as a single question on here :( --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- void Business::addGamesFromFile() {...
C++
please make it sifferent and unique
Description Write a program that will read data from the file "p6.dat". The file (that you will create) always contains 15 test scores (whole numbers between O and 100). The test scores are scores for 5 students taking 3 tests, and are arranged, in the file, by the student - that is the first 3 numbers are the test scores for test 1, 2, and 3 for the first student, etc. The program...
Can anyone help me with my C hw?
Exercise 3 You will write a new program that combines dynamically allocating an array and saving that array to a file. These are the tasks your program must perform Open an output file named "data.txt" and prepare it for writing in text mode o If the file handle is NULL, quit the program o By default, it is created and stored in the same directory as your source code file Prompt the...
In c++ Write a program that contains a class called Player. This class should contain two member variables: name, score. Here are the specifications: You should write get/set methods for all member variables. You should write a default constructor initializes the member variables to appropriate default values. Create an instance of Player in main. You should set the values on the instance and then print them out on the console. In Main Declare a variable that can hold a dynamcially...
C++ Redo PROG8, a previous program using functions and/or arrays. Complete as many levels as you can. Level 1: (20 points) Write FUNCTIONS for each of the following: a) Validate #students, #scores. b) Compute letter grade based on average. c) Display student letter grade. d) Display course average. Level 2: (15 points) Use ARRAYS for each of the following. e) Read a student's scores into array. f) Calculate the student's average based on scores in array. g) Display the student's...
In C, write a program to read 5 student scores from keyboard the average of test score. Use for loop. Instead of entering the 5 scores each time you run the program, you can use i/o redirect. Create an input file inputfor.txt, then add 5 scores in it. Run the command like this: scorefor < inputfor.txt