Question

USE C++ FOR THE CODE THAT CAN RUN IN VISUAL STUDIO 2019 (or a complier)

Write a program YourName-Assignments (replace Your Name with your actual name, no spaces) that reads from students records (

Ignore the last paragraph on the bottom of the page!

1 The program should work on any file with that format with different numbers of line. Do not hardcode the number of line, co\

95 Anderson Blake 75.5 Cruz 55 Dang 95 Engberg 80 Farris 55 Garcia 93.6 Hadad 25 Ionescu 100 Johnson 75 Kaloo 75 Lagos 55.5 M

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:-

#include<iostream>

#include<iomanip>

#include<fstream>

#include<string>

using namespace std;

char getGrade(double score){

if(score>=89.5 && score<=100)

return 'A';

else if(score>=79.5 && score<=89.49)

return 'B';

else if(score>=69.5 && score<=79.49)

return 'C';

else if(score>=59.5 && score<=69.49)

return 'D';

else if(score>=0 && score<=59.49)

return 'F';

}

int main(){

ifstream in;

in.open("StudentsGrades.txt");

if(in.fail()){

cout<<"Unable to open file"<<endl;

return -1;

}

string name;

double test_grade, assign_grade, total_points, numeric_grade;

cout<<setprecision(2)<<fixed;

cout<<"STUDENT STATISTICS"<<endl;

cout<<setw(15)<<left<<"Student Name"<<setw(15)<<"Tests Grade"<<setw(15)<<"Assign. Grade"<<setw(15)<<"Total Points"<<setw(15)<<"Numeric Grade"<<setw(15)<<"Letter Grade"<<endl;

int n = 0;

double avg = 0.0;

while(!in.eof()){

in>>name>>test_grade>>assign_grade;

total_points = test_grade+assign_grade;

numeric_grade = total_points/2.0;

cout<<setw(15)<<left<<name<<setw(15)<<test_grade<<setw(15)<<assign_grade<<setw(15)<<total_points<<setw(15)<<(total_points/2)<<setw(15)<<getGrade(numeric_grade)<<endl;

avg+=numeric_grade;

n++;

}

avg /= n;

cout<<"\nCLASS STATISTICS"<<endl;

cout<<"Number:\t\t"<<n<<endl;

cout<<"Average:\t"<<avg<<endl;

return 0;

}

Output Screenshot:-

nagarajuanagaraju-Vostro-3550:-/Desktop/CHEGG/October/28102018$ g++ grades.cpp nagarajuanagaraju-Vostro-3550:-/Desktop/CHEGG/

-----------------------------------

Please give me a UPVOTE. Thank you :)

Add a comment
Know the answer?
Add Answer to:
USE C++ FOR THE CODE THAT CAN RUN IN VISUAL STUDIO 2019 (or a complier) Ignore...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The Computer Science Instructor has just completed compiling all the grades for the C++ Programming class....

    The Computer Science Instructor has just completed compiling all the grades for the C++ Programming class. The grades were downloaded into a file titled ‘studentGrades.txt’ (attached). Write a C++ Program that reads this file and calculates the following as described : The final semester numeric and letter grade (using 10 point scale) Calculated as follows: Labs 1-6 (worth 50% of final grade) Lab 7 is extra credit (worth 2 % of final grade OR replaces lowest lab grade – Select...

  • In C Langage Write a grading program for a class with the following grading policies:- a. There are two quizzes, each gr...

    In C Langage Write a grading program for a class with the following grading policies:- a. There are two quizzes, each graded on the basis of 10 points. b. There is one midterm exam and one final exam, each graded on the basis of 100 points. c. The final exam counts for 50 percent of the grade, the midterm counts for 25 percent and the two quizzes together count for a total of 25 percent. Grading system is as follows:-...

  • Please help me with this program.You are to write a C++ program that will read in...

    Please help me with this program.You are to write a C++ program that will read in up to 15 students with student information and grades. Your program will compute an average and print out certain reports. Format: The information for each student is on separate lines of input. The first data will be the student�s ID number, next line is the students name, next the students classification, and the last line are the 10 grades where the last grade is...

  • Java Program: In this project, you will write a program called GradeCalculator that will calculate the...

    Java Program: In this project, you will write a program called GradeCalculator that will calculate the grading statistics of a desired number of students. Your program should start out by prompting the user to enter the number of students in the classroom and the number of exam scores. Your program then prompts for each student’s name and the scores for each exam. The exam scores should be entered as a sequence of numbers separated by blank space. Your program will...

  • C++: Create a grade book program that includes a class of up to 20 students each...

    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...

  • In this assignment, you will write a program in C++ which uses files and nested loops...

    In this assignment, you will write a program in C++ which uses files and nested loops to create a file from the quiz grades entered by the user, then reads the grades from the file and calculates each student’s average grade and the average quiz grade for the class. Each student takes 6 quizzes (unknown number of students). Use a nested loop to write each student’s quiz grades to a file. Then read the data from the file in order...

  • c++ implement a student class Determine the final scores, letter grades, and rankings of all students...

    c++ implement a student class Determine the final scores, letter grades, and rankings of all students in a course. All records of the course will be stored in an input file, and a record of each student will include the first name, id, five quiz scores, two exam scores, and one final exam score. For this project, you will develop a program named cpp to determine the final scores, letter grades, and rankings of all students in a course. All...

  • This is in C++. Example: You will write a program that will prompt the user to...

    This is in C++. Example: You will write a program that will prompt the user to enter a grade out of 100 and then show them what the equivalent grade points value is. The main() function will handle the input and output tasks, but the actual conversion will occur in a function called GradePoints(). GradePoints Specifications This function is strictly a processing function, meaning that there are no console input or output steps in the actual function. Consider that this...

  • Please program in C++ and document the code as you go so I can understand what...

    Please program in C++ and document the code as you go so I can understand what you did for example ///This code does~ Your help is super appreciated. Ill make sure to like and review to however the best answer needs. Overview You will revisit the program that you wrote for Assignment 2 and add functionality that you developed in Assignment 3. Some additional functionality will be added to better the reporting of the students’ scores. There will be 11...

  • THIS IS FINAL COURSE ASSIGNMENT, PLEASE FOLLOW ALL REQUIREMENTS. Hello, please help write program in JAVA...

    THIS IS FINAL COURSE ASSIGNMENT, PLEASE FOLLOW ALL REQUIREMENTS. Hello, please help write program in JAVA that reads students’ names followed by their test scores from "data.txt" file. The program should output "out.txt" file where each student’s name is followed by the test scores and the relevant grade, also find and print the highest test score and the name of the students having the highest test score. Student data should be stored in an instance of class variable of type...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT