Question

Please help me to write a program in C++ with comments and to keep it simple as possible. Also, post the output please.

Thank you!

C++ File LO Using notepad or textpad, create a text file with the following data shown below, without the headings. Course Credits Grade Student ID Number Student Name Course Code Course 2333021 2333021 2333021 2574063 2574063 2574063 2574063 663628 2663628 2663628 2663628 2663628 BOKOW, R BOKOW, BOKOW,R FALLIN, D FALLIN, D FALLIN, D FALLIN, D KINGSLEY, M KINGSLEY, M KINGSLEY, M KINGSLEY, M KINGSLEY, M NS201 MG342 FA302 MK106 MA208 CM201 CP101 QA140 CM245 EQ521 MK341 CP101 Write a C+program that creates student grade reports. Save the report in a file called studentGrades.rpt. The grade report for each student should contain the students name and ID number, a list of courses taken, the credits and grade for each course, and a semester grade point average (GPA). For example, this is the grade for the first student Student Name: BOKOW,R. Student ID Number 2333021 Course Credits Course Grade Course Code NS201 MG342 FA302 Total Semester Course Credits Completed: 7 Semester GPA: 4.0 The semester GPA is computed in two steps. First, each course grade is assigned a numerical value (A-4, B-3, C-2, D-1, F-0), and the sum of each courses grade value times the credits for each course is computed. The sum is then divided by the total number of credits taken during the semester

Here is input data:

2333021 BOKOW, R. NS201 3 A
2333021 BOKOW, R. MG342 3 A
2333021 BOKOW, R. FA302 1 A
2574063 FALLIN, D. MK106 3 C
2574063 FALLIN, D. MA208 3 B
2574063 FALLIN, D. CM201 3 C
2574063 FALLIN, D. CP101 2 B
2663628 KINGSLEY, M. QA140 3 A
2663628 KINGSLEY, M. CM245 3 B
2663628 KINGSLEY, M. EQ521 3 A
2663628 KINGSLEY, M. MK341 3 A
2663628 KINGSLEY, M. CP101 2 B

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

if you have any doubts, please give me comment...

#include<iostream>

#include<string>

#include<iomanip>

#include<fstream>

using namespace std;

int getPoints(char grade);

int main(){

//opening instance for opening file

ifstream in;

in.open("studentGrades.txt");

//if file is not open, the print error message terminate the program

if(in.fail()){

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

return -1;

}

//opening instance for write report into file

ofstream out;

out.open("studentGrades.rpt");

string fname, mInitial, courseName;

int credits, id, prev_id=-1, total_credits = 0;

char grade;

double gpa = 0.0;

//setting 1 decimal after cgpa

out<<setprecision(1)<<fixed;

//iterating over the file

while(!in.eof()){

//reading input from file

in>>id>>fname>> mInitial>>courseName>>credits>>grade;

//checking to whether print summary or course details, if student changes we will go with summary, not we will go with course details

if(id==prev_id){

out<<courseName<<"\t\t\t"<<credits<<"\t\t"<<grade<<endl;

//adding credits to total

total_credits += credits;

//getting student credits for grade

gpa += credits*getPoints(grade);

}

else{

if(prev_id!=-1){

//printint summary except first record

gpa = gpa/total_credits;

out<<endl<<"Total Semester Course Credits Completed: "<<total_credits<<endl;

out<<"Semester GPA: "<<gpa<<endl;

}

total_credits = 0;

gpa = credits*getPoints(grade);

//printing details of student into file

out<<"\nStudent Name: "<<fname<<" "<<mInitial<<endl;

out<<"Student ID Number: "<<id<<endl<<endl;

//printing course details into file

out<<"Course Code\tCourse Credits\tCourseGrade"<<endl;

out<<"------------------------------------------------------"<<endl;

out<<courseName<<"\t\t\t"<<credits<<"\t\t"<<grade<<endl;

total_credits += credits;

prev_id = id;

}

}

gpa = gpa/total_credits;

out<<"\nTotal Semester Course Credits Completed: "<<total_credits<<endl;

out<<"Semester GPA: "<<gpa<<endl;

//closing input and output files

in.close();

out.close();

return 0;

}

int getPoints(char grade){

if(grade=='A')

return 4;

else if(grade=='B')

return 3;

else if(grade=='C')

return 2;

else if(grade=='D')

return 1;

else

return 0;

}

Add a comment
Know the answer?
Add Answer to:
Please help me to write a program in C++ with comments and to keep it simple...
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
  • Program 5 Due 10/25 C-String and Two-dimensional Array Use An input data file starts with a...

    Program 5 Due 10/25 C-String and Two-dimensional Array Use An input data file starts with a student's name (on one line). Then, for each course the student took last semester, the file has 2 data lines. The course name is on the first line. The second line has the student's grade average (0 to 100) and the number of credits for the course Sample data: Jon P. Washington, Jr. Computer Science I 81 4 PreCalculus 75 3 Biology I 88...

  • Problem Specification: Write a C++ program to calculate student’s GPA for the semester in your class. For each student, the program should accept a student’s name, ID number and the number of courses...

    Problem Specification:Write a C++ program to calculate student’s GPA for the semester in your class. For each student,the program should accept a student’s name, ID number and the number of courses he/she istaking, then for each course the following data is needed the course number a string e.g. BU 101 course credits “an integer” grade received for the course “a character”.The program should display each student’s information and their courses information. It shouldalso display the GPA for the semester. The...

  • Write a C++ program to store and update students' academic records in a binary search tree....

    Write a C++ program to store and update students' academic records in a binary search tree. Each record (node) in the binary search tree should contain the following information fields:               1) Student name - the key field (string);               2) Credits attempted (integer);               3) Credits earned (integer);               4) Grade point average - GPA (real).                             All student information is to be read from a text file. Each record in the file represents the grade information on...

  • Hello I need help fixing my C++ code. I need to display in the console the...

    Hello I need help fixing my C++ code. I need to display in the console the information saved in the file as well have the content saved in the file output in a fixed position like the screenshot. Thanks. CODE #include<iostream> #include<fstream> #include<iomanip> using namespace std; //main function int main() {    //variable to store student id    int id;       //variables to store old gpa(ogpa), old course credits(occ), new course credits(ncc), current gpa(cur_gpa), cumulative gpa(cum_gpa)    float ogpa,...

  • In C++ Write a menu driven C++ program to read a file containing information for a list of Students, process the data, t...

    In C++ Write a menu driven C++ program to read a file containing information for a list of Students, process the data, then present a menu to the user, and at the end print a final report shown below. You may(should) use the structures you developed for the previous assignment to make it easier to complete this assignment, but it is not required. Required Menu Operations are: Read Students’ data from a file to update the list (refer to sample...

  • (7) Student grade point statistics [Problem description] There is a need to make statistics of the grade points o...

    (7) Student grade point statistics [Problem description] There is a need to make statistics of the grade points of the students in the first semester of 2018. It is assumed that there are n (can be set as 6) classes in this grade, and there are 20 students in each class, the total number of courses with exam is m (can be set as 10), and the percentage system is adopted for each course. The gpa is 4, 3, 2,1,...

  • 12.8 GPA reports using files This program is to compute and write to a file the...

    12.8 GPA reports using files This program is to compute and write to a file the GPA for student scores read from an input file. As in Lab 7.5, the point values of the grades are 4 for A, 3 for B, 2 for C, 1 for D, and 0 for F. Except for the grade A, where + has no effect, a + after the letter increases the point value by 0.3, and except for F, where a -...

  • Consider the following set of requirements for a university database that is used to keep track...

    Consider the following set of requirements for a university database that is used to keep track of students' transcripts The university keeps track of each student's name, student number, social security number, address and phone, birthdate, gender, `, and degree program (bachelor, Masters, PhD.). Both social security number and student number have unique values for each student. Each department is described by a name, department code, office number, office phone. Both name and code have unique values for each department....

  • Create sql queries to find the following miscrosoft access compatible commands please 9. Courses for which...

    Create sql queries to find the following miscrosoft access compatible commands please 9. Courses for which at least three students earned a grade of A, showing the grade and the course code 10. Semesters when the highest number of courses have been scheduled, showing the semester name and the number of sections 11. (Extra) Professors that are not students, and students that are not professors, showing their ID and SSN 12. (Extra) Semesters for which all courses are taught by...

  • In JAVA please! Write program for exercises You will write a Graphical User Interface(GUI) application to manage student...

    In JAVA please! Write program for exercises You will write a Graphical User Interface(GUI) application to manage student information system. The application should allow: 1. Collect student information and store it in a binary data file. Each student is identified by an unique ID. The user should be able to view/edit an existing student. Do not allow student to edit ID. 2. Collect Course information and store it in a separate data file. Each course is identified by an unique...

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