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

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 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,...
Write a C program that calculates a student grade in the C Programming Class. Ask the...
Write a C program that calculates a student grade in the C Programming Class. Ask the user to enter the grades for each one of the assignments completed in class: Quiz #1 - 25 points Quiz #2 - 50 points Quiz #3 - 30 points Project #1 - 100 points Project #2 - 100 points Final Test - 100 points The total of the quizzes count for a 30% of the total grade, the total of the projects counts for...
C++ Bubble Sort Write a program that ask user to enter 7 numbers and store that...
C++ Bubble Sort Write a program that ask user to enter 7 numbers and store that in array. Display that all numbers before and after performing Bubble sort. You must have to create new function with required parameter to perform Bubble sort. Sample Run :- Enter 1 number :- 1 Enter 2 number :- 5 Enter 3 number :- 7 Enter 4 number :- 45 Enter 5 number :- 90 Enter 6 number :- 6 Enter 7 number :- 55...
Write a C++ program that design a class definition to be put in a header file...
Write a C++ program that design a class definition to be put in a header file called fizzjazz.h A store sells online FizzJazz which are sound tones made by famous bands. For each FizzJazz, the store wants to keep track of the following attributes: * title - the name of the sound tone * band - Famous band name that created the tone * duration - this is in seconds and may be fractional: examples: 20.0, 34.5 Each attribute will...
Write a C++ program that design a class definition to be put in a header file...
Write a C++ program that design a class definition to be put in a header file called fizzjazz.h A store sells online FizzJazz which are sound tones made by famous bands. For each FizzJazz, the store wants to keep track of the following attributes: * title - the name of the sound tone * band - Famous band name that created the tone * duration - this is in seconds and may be fractional: examples: 20.0, 34.5 Each attribute will...
Write a C++ program that design a class definition to be put in a header file...
Write a C++ program that design a class definition to be put in a header file called fizzjazz.h A store sells online FizzJazz which are sound tones made by famous bands. For each FizzJazz, the store wants to keep track of the following attributes: * title - the name of the sound tone * band - Famous band name that created the tone * duration - this is in seconds and may be fractional: examples: 20.0, 34.5 Each attribute will...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT