Question

In: Computer Science

There will be three grades for each student in "grades.txt" (see example file bellow). In "student.txt"...

There will be three grades for each student in "grades.txt" (see example file bellow). In "student.txt" there are two students first and last names. In "grades.txt" the grades for each student will be on the same line number as the students name was on in "students.txt".

So if line 1 of "students.txt" contains:

Joe Blow

then line 1 of "grades.txt" would contain Joe Blow's grades:

85 54.3 56

Into an output file called "report.txt" output the student's last name then a comma the their first name. Following this, calculate their average and assign a letter grade using the following scale:

'A': grade >= 90

'B': 90 > grade >= 80

'C': 80 > grade >= 70

'D': 70 > grade >= 60

'F': grade < 60

If the final grade of a student is greater than 100 instead of printing their letter grade output the statement "Teacher was far too easy". The "report.txt" should have a heading on each of the columns the first saying "Student's Name" and the second saying "Student's Grade".

Solutions

Expert Solution

//C++ program

#include<iostream>
#include<fstream>
using namespace std;

char findLetterGrade(double marks){
   if(marks>=90)return 'A';
   if(marks>=80)return 'B';
   if(marks>=70)return 'C';
   if(marks>=60)return 'D';
   return 'F';
}

int main(){
   ifstream in1,in2;
   ofstream out;
  
   string firstName,lastName;
   int grade1,grade2,grade3;
   double average;
   char letterGrade;
  
  
   in1.open("students.txt");
   in2.open("grades.txt");
   out.open("report.txt");
  
   if(!in1){
       cout<<"grades file not opened\n";
       return 0;
   }
   if(!in2){
       cout<<"students file not opened\n";
       return 0;
   }
   if(!out){
       cout<<"report file not opened\n";
       return 0;
   }
   out<<"Student's Name\tStudent's Grade\n";
  
   while(!in1.eof() && !in2.eof()){
       in1>>firstName>>lastName;
       in2>>grade1>>grade2>>grade3;
      
       average = (double)(grade1+grade2+grade3)/3;
      
       letterGrade = findLetterGrade(average);
      
       out<<lastName<<","<<firstName<<"\t\t";
       if(average<=100)out<<letterGrade<<"\n";
       else out<<"Teacher was far too easy\n";
   }
   in1.close();
   in2.close();
   out.close();
   return 0;
}


Related Solutions

Work through the National Budget Simulation ( SEE LINK BELLOW) . in an effort to achieve...
Work through the National Budget Simulation ( SEE LINK BELLOW) . in an effort to achieve a budget deficit of $1100B dollars. Scenario: The President of the United States has been elected on the promise of fiscal responsibility. By law he cannot reduce the net interest paid on the debt. The President's budget is projected to leave the country with a $1100B deficit. The United States is subject to global security concerns. At the same time, a lingering recession and...
Find the GPA of the following grades. A student received the following grades. C     in Math...
Find the GPA of the following grades. A student received the following grades. C     in Math 120   worth 4 credits. B      in English 125 and worth 3 credits A in Chem 102 and worth 5 credits. According to Empirical Rule, the mean is 35 and the standard deviation is 3. 68 % of the data lie between what values. 95% of the data lie between what values 99.7 % of the data lie between what values Given the following data....
A professor is studying to see if there is a relationship between the grades and gender...
A professor is studying to see if there is a relationship between the grades and gender of his students. He picks a random sample of his students and notes their grades (A, B, or C) and their gender (male or female). He finds that: 28% are A students. 58% are B students. 62% of his students are female. Of those who are female, one-third are A students. Of those who are B students, three-fifths are female students. What percentage of...
A professor is studying to see if there is a relationship between the grades and gender...
A professor is studying to see if there is a relationship between the grades and gender of his students. He picks a random sample of his students and notes their grades (A, B, or C) and their gender (male or female). He finds that: 28% are A students. 58% are B students. 62% of his students are female. Of those who are female, one-third are A students. Of those who are B students, three-fifths are female students. What percentage of...
To encourage good grades, Hermosa High School has decided to award each student a bookstore credit...
To encourage good grades, Hermosa High School has decided to award each student a bookstore credit that is 10 times the student’s grade point average. In other words, a student with a 3.2 grade point average receives a $32.0 credit. Create an application that prompts a student for a name and grade point average, and then passes the values to a method (computeDiscount) that displays a descriptive message. The message uses the student’s name, echoes the grade point average, and...
The two BELLOW examples illustrate the benefits of research WHICH ONE IS AN EXAMPLE OF BAISIC...
The two BELLOW examples illustrate the benefits of research WHICH ONE IS AN EXAMPLE OF BAISIC RESEARCH, AND WHICH ONE AN EXAMPLE APPLIED RESEARCH EXAMPLE ONE Globally, colas account for more than 50% of all sodas sold. The challenge for the $187 billion soft drink industry is giving consumers in developed markets the sugary taste they want without giving them the mouthful of calories they don’t. Concerns about obesity and health have led to nine years of falling U.S. soda...
The C++ problem: Student marks are kept in a text file as a single column. Each...
The C++ problem: Student marks are kept in a text file as a single column. Each student may have a different number of assessments and therefore scores. The data recorded in the file for each student start with the number of scores for the student. This is followed by the student id and then several marks student scored in various assessments, one score per line. A small segment of the file might look like the following: (file name is marks.txt)...
JAVASCRIPT: Please create an array of student names and another array of student grades. - Create...
JAVASCRIPT: Please create an array of student names and another array of student grades. - Create a function that can put a name and a grade to the arrays. - Keep Read student name and grade until student name is “???”. And save the reading by using a function - Create another function to show all the grade in that object. - Create the third function that can display the maximum grade and the student’s name. - Create a sorting...
Write a program in python to read from a file the names and grades of a...
Write a program in python to read from a file the names and grades of a class of students to calculate the class average, the maximum, and the minimum grades. The program should then write the names and grades on a new file identifying the students who passed and the students who failed. The program should consist of the following functions: a) Develop a getGrades() function that reads data from a file and stores it and returns it as a...
Using the accompanying Student Grades​ data, construct a scatter chart for midterm versus final exam grades...
Using the accompanying Student Grades​ data, construct a scatter chart for midterm versus final exam grades and add a linear trendline. What is the​ model? If a student scores 70 on the​ midterm, what would you predict her grade on the final exam to​ be? Student Midterm Final Exam 1 7575 6464 2 8585 9090 3 8080 6969 4 8989 8484 5 7676 6161 6 6666 7878 7 7878 7272 8 9494 9494 9 6767 5959 10 9393 8686 11...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT