Question

In: Computer Science

n-class: Write a program to store exam scores into a file. The program will ask the...

n-class: Write a program to store exam scores into a file. The program will ask the user how many exam scores to enter. Then it will ask the user for each exam score and store them in a file called scores.dat The file output should have the following format . Exam 1: 97 Exam 2: 85

C++ Coding please

Solutions

Expert Solution

The code for the above problem is:-

#include<iostream>
using namespace std;
#include<fstream>
main(){
int limit,score; // variables to store the number of scores and the value of each score,respectively

cout<<"How many exam scores do you want to enter? \n"; //prompting the user for the number of scores he/she wants to enter
cin>>limit; //storing the number of exams for which the use wants to enter the value
cout<<"please enter the scores\n"; //prompting the user to enter the scores foe each exam
ofstream myfile; // declaring a pointer(myfile) to the file
myfile.open("scores.dat"); //opening a file named scores.dat
for(int i=1;i<=limit;i++) //loop for storing the values entered by the user into the file
{
   cin>>score; //storing the values into the variable
   myfile<<"Exam "<<i<<": "<<score<<"\n"; // storing the values into the file as per desired format
}
myfile.close(); //closing the file
}

The Screenshots of the code,output and the stored values in the file are given below:-

Code:-

Output screen:-

Store values in the file:-

Note:- The file "Scores.dat" will be generated in the location in which you save your code.


Related Solutions

In C++ Write a program to store exam scores into a file. The program will ask...
In C++ Write a program to store exam scores into a file. The program will ask the user how many exam scores to enter. Then it will ask the user for each exam score and store them in a file called scores.dat The file output should have the following format: Exam 1: 97 Exam 2: 85
In java, Write a program that reads a data file containing final exam scores for a...
In java, Write a program that reads a data file containing final exam scores for a class and determines the number of passing scores (those greater than 60) and the number of failing scores (those less than 60). The average score as well as the range of scores should also be determined. The program should request the name of the data file from the end user. The file may contain any number of scores. Using a loop, read and process...
Write a program for a beauty store that uses an InputBox to ask the guest for...
Write a program for a beauty store that uses an InputBox to ask the guest for a membership code. Embed this in a Do loop so that the user has to keep trying until the result is a valid membership code that starts with “Beauty” (case insensitive) and is followed by 4 digits with the final digit equal to either 6 or 8. Then use a message box to display the input promotion code and inform the user that the...
Write a program in Java to: Ask the user how many scores they want to enter...
Write a program in Java to: Ask the user how many scores they want to enter (=> Create an array based the entered size) Ask the user to enter their scores in the quarter (Fill the array with the entered scores(assigned to elements)) ==>> Use a "for" loop Find the greatest score Calculate and show the average Show the final grade based on the average (For example A,B,C ... ) Print the scores (the elements of the array) => Use...
Write a program in C to grade an n-question multiple-choice exam (for n between 5 and...
Write a program in C to grade an n-question multiple-choice exam (for n between 5 and 20) and provide feedback about the most frequently missed questions. Your program will use a function scan_exam_data to scan and store the exam data in an appropriate data structurer. Use file redirection to input data – do not use fopen() in your code. The first line of input contains the number of students. Second line is number of questions on the exam followed by...
Question6: Write a program to read the file 202010mid.txt, store the content in a list of...
Question6: Write a program to read the file 202010mid.txt, store the content in a list of tuples, then print the list. [6 marks] Question7: Write Python code to do the following operations using request library. [12 marks] Check if the following webpage is available or not: https://edition.cnn.com/news.html [4 marks] Send a get request to the following webpage and show the result: http://api.open-notify.org/iss-pass.json [4 marks] The webpage from part 2 is expecting some parameters as shown from the results. Now create...
Write a java program that will read a file called stateinfo.txt and will store the information...
Write a java program that will read a file called stateinfo.txt and will store the information of the file into a map. The stateinfo.txt file contains the names of some states and their capitals. The format of stateinfo.txt file is as follows. State                Capital ---------                         ----------- NSW               Sydney VIC                 Melbourne WA                 Perth TAS                 Tasmania QLD                Brisbane SA                   Adelaide The program then prompts the user to enter the name of a state. Upon receiving the user input, the program should...
Write a C++ program that reads a file consisting of students’ test scores in the range...
Write a C++ program that reads a file consisting of students’ test scores in the range 0–200. It should then determine the number of students having scores in each of the following ranges: 0–24, 25–49, 50–74, 75–99, 100–124, 125–149, 150–174, and 175–200. Output the score ranges and the number of students. (Run your program with the following input data: 76, 89, 150, 135, 200, 76, 12, 100, 150, 28, 178, 189, 167, 200, 175, 150, 87, 99, 129, 149, 176,...
Suppose a professor gives an exam to a class of 40 students and the scores are...
Suppose a professor gives an exam to a class of 40 students and the scores are as follows. (Type the data set in StatCrunch.) 35 44 46 47 47 48 49 51 53 54 55 55 57 57 57 58 59 59 59 59 60 60 60 60 60 62 62 62 64 68 69 70 72 73 73 75 75 77 82 88 Top 10% of scores receive an A Bottom 10% of scores receive an F Scores between...
Imagine there are five students in a class. Their scores on the midterm exam are: 93,...
Imagine there are five students in a class. Their scores on the midterm exam are: 93, 85, 70, 78, and 64. Calculate the mean, the variance and the standard deviation and interpret the meaning of the variance and standard deviation.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT