#include <fstream>
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main(){
ifstream inFile1;
string file_name,tmp;
cout<<"Enter the input file name (with
extension <= 50 characters): "; //Enterring the file name
cin>>file_name;
cout<<endl;
inFile1.open(file_name); //opening the
file
if (!inFile1) {
cerr << "Unable to open file
"<<file_name<<endl; //checking if file opened without
any error
exit(1); // call system to stop
}
int x,count=0;
while(!inFile1.eof()){
inFile1>>x;
count++; //count of
students
}
inFile1.close();
inFile1.open(file_name);
int marks[count];
//array to store marks
int marks_range[8]={0,0,0,0,0,0,0,0};
//array to store count of marks in each range
for(int i=0;!inFile1.eof();i++) {
inFile1>>marks[i]; // storing
marks in an array
}
inFile1.close();
cout<<std::string(50, '-')<<endl;
cout<<"The total number of students is:
"<<count<<endl; //printing the total number
of students
cout<<std::string(50, '-')<<endl;
for(int i=0;i<count;i++){
//counting the numbers of marks in a range
if(marks[i]>=0 &&
marks[i]<=24){
marks_range[0]++;
}
else if(marks[i]>=25 &&
marks[i]<=49){
marks_range[1]++;
}
else if(marks[i]>=50 &&
marks[i]<=74){
marks_range[2]++;
}
else if(marks[i]>=75 &&
marks[i]<=99){
marks_range[3]++;
}
else if(marks[i]>=100 &&
marks[i]<=124){
marks_range[4]++;
}
else if(marks[i]>=125 &&
marks[i]<=149){
marks_range[5]++;
}
else if(marks[i]>=150 &&
marks[i]<=174){
marks_range[6]++;
}
else{
marks_range[7]++;
}
}
int lower,upper;
for(int i=0;i<8;i++){ //printing the
count of marks in each range
if(i==7){
lower=175;
upper=200;
}
else{
lower=i*25;
upper=lower+24;
}
tmp=to_string(lower)+" -
"+to_string(upper);
cout<<left<<setw(15)<<tmp;
cout<<marks_range[i]<<endl;
}
cout<<std::string(50, '-')<<endl;
cout<<"Students scores and
grades"<<endl;
cout<<std::string(50, '-')<<endl;
float avg;
for(int i=0;i<count;i++){ //printing
the grades based on average
cout<<right<<setw(2)<<i+1<<". Student
score: ";
cout<<left<<setw(3)<<marks[i]<<" = Grade:
";
avg=(marks[i]/200.0)*100;
if(avg>=90.0 &&
avg<=100.0){
cout<<'A'<<endl;
}
else if(avg>=80.0 &&
avg<90.0){
cout<<'B'<<endl;
}
else if(avg>=70.0 &&
avg<80.0){
cout<<'C'<<endl;
}
else if(avg>=60.0 &&
avg<70.0){
cout<<'D'<<endl;
}
else{
cout<<'F'<<endl;
}
}
cout<<std::string(50, '-')<<endl;
}
codeblock c++ language Write a program that reads students test scores in the range 0-200 from...
written in c++ Write a 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,...
This needs to be linux compatible in C++ code. Write a 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,...
This is a revision of a previous exercise, here is the question: Perform exercise 4 at the end chapter 8 of your textbook using dynamic arrays. (This time the program must use dynamic arrays). I have regular array version posted below. C++: Write a 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,...
Write a complete C++ program that reads students names and their test scores from an input text file. The program should output each student’s name followed by the test scores and the relevant grade in an output text file. It should also find and display on screen the highest/lowest test score and the name of the students having the highest/lowest test score, average and variance of all test scores. Student data obtained from the input text file should be stored...
C++: Create a grade book program that includes a class of up to 20 students each with 5 test grades (4 tests plus a Final). The sample gradebook input file (CSCI1306.txt) is attached. The students’ grades should be kept in an array. Once all students and their test scores are read in, calculate each student’s average (4 tests plus Final counts double) and letter grade for the class. The output of this program is a tabular grade report that is...
C++ program that reads students' names followed by their test scores (5 scores) from the given input file, students.txt. The program should output to a file, output.txt, each student's first name, last name, followed by the test scores and the relevant grade. All data should be separated by a single space. Student data should be stored in a struct variable of type StudentType, which has four components: studentFName and studentLName of type string, an array of testScores of type int...
Could someone help me out here assignment due tonight. Thank you. Develop and run problem 03 page 231. Make a function to output your results. Read the following data into your program from a text file that you make. (Use 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, 200, 87, 35, 157, and 189.) Hint: to make a file use notepad++ input and...
C++ Write a program that reads students’ names followed by their test scores from the given input file. The program should output to a file, output.txt, each student’s name followed by the test scores and the relevant grade. Student data should be stored in a struct variable of type StudentType, which has four components: studentFName and studentLName of type string, testScore of type int and grade of type char. Suppose that the class has 20 students. Use an array of...
please use the c language Assignment 12 The program to write in this assignment is a program that calculates score statistics and manages the grades of the students. First, the student list and are given in a file named "student.dat" as in the following: 이성우 77 홍길동 88 scores 201 1710086 2012700091 This program reads the input file "student.dat" and keeps this data in a linear linked list. Each node must be a struct which contains the following: student id...
Write a program in C language that reads scores and id numbers from a file, finds the average score, and assigns each student a grade based on the following rules: Each score > average + 20 gets an A Each score between average + 10 and average + 20 gets a B Each score between average - 10 and average + 10 gets a C Each score between average - 20 and average - 10 gets a D Each score...