Question

Weighted GPA Calculator2 Many schools factor in the number of credits each course is worth, meaning a 4-credit class has more value than a 2-credit class when calculating students GPA Suppose the following were the grades for a student CreditsGrade lass Pre-Calculus History Chemistry Physical Education 1 Letter grades are assigned as follows Letter grades are worth these points 0-60 F 61 -70 D 71 80 C 81 -90 B 91 -100 A Class Pre-Calculus History Chemistr)y Physical Education 1 Total Credits Grade Points Total 16 13 32 To find the GPA weighted by credit hours, follow these steps: Multiply each Letter grade points by the number of credits the course was worth. For Pre-Calculus for example (2x48 points) Add the points for all four courses together Divide the sum (32 in our example) by the total number of credits, in this example, 9 Weighted by Credit Hour GPA 3.56 (calculated as 32/9) In comparison, if you weighted these grades using the Simple GPA method the GPA would be 3.25 (calculated as (13/4) Write a program that calculates and displays the GPA for a class of 5 students taking the above 4 courses Each student is represented by a Student struct as shown below. Fill a vector of Student structures with data for each student For each student pull a random number between 60-100 inclusive for each of the 4 courses they Calculate their weighted GPA based on the above criteriaDeclare the following as global (outside of main)) const int NUM STUDENTS 5; const int NUM SCORES 4; const int CREDITS-2, 2, 4, 1] й credits for each of the four courses struct Student { int int char int in double gpa; idNumber,; raw_scores[NUM_SCORES]; letter_grades[NUM_SCORES];II weighted_scores[NUM_SCORES] I/ totalPoints; // Example 0039 [95, 85, 94, 75] [ A, B, A, C] [ 8, 6, 16, 2] 32 3.56 The Student variable totalPoints holds the result of multiplying the number of credits by the letter grade point values (2x4 + 2x3 + 4x4 + 1x2- 32) Note: No other variable, array or vector may be declared as global Sample output S1G1 S2G2 S3G3 S4G4 Total GPA 0039 71 C 60 F 78 C 100 A 161.23 1799 61 D 78 C 96 A 86 B 25 1.92 5854 75 C 95 A 95 A 97 A 32 2.46 9 0.69 0979 94 A 67 D 95 A 67 D 27 2.08 5923 67 D 64 D 64D 62 D Points 2 No global variables, arrays or vectors other than the two constants and the structure 2 The main) function should be at the top with function prototypes. 4 correct GPA calculation. GPA display to 2 decimals 2 display of the four numeric grades 2 display of the four letter grades 2 display of student ld as a random number 1-9999 with no duplicates student ld is prefixed with zeros if it has less than four digits 1 correct results if NUM_STUDENTS and NUM_SCORES are changed. 15 Suggestions Use helper functions instead of having too many lines of code in any one function Develop your program incrementally, compile and run often Use cout<< statements to display the values of variables when trying to find program errorsuse c++

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

#include<vector>

#include<cstdlib>

using namespace std;

const int NUM_STUDENTS = 5;

const int NUM_SCORES = 4;

const int CREDITS[] = {2, 2, 4, 1};

struct Student{

int idNumber;

int raw_scores[NUM_SCORES];

char letter_grades[NUM_SCORES];

int weighted_scores[NUM_SCORES];

int totalPoints;

double gpa;

};

char getLetterGrade(int score);

int gradePoints(char grade);

int main(){

vector<Student> scores;

Student temp;

for(int i=0; i<NUM_STUDENTS; i++){

bool alreadyExist = true;

while(alreadyExist){

temp.idNumber = (rand()%9998)+1;

alreadyExist = false;

for(int j=0; j<i; j++){

if(scores[j].idNumber==temp.idNumber){

alreadyExist = true;

break;

}

}

}

temp.totalPoints = 0;

for(int j=0; j<NUM_SCORES; j++){

temp.raw_scores[j] = (rand()%40)+60;

temp.letter_grades[j] = getLetterGrade(temp.raw_scores[j]);

temp.weighted_scores[j] = gradePoints(temp.letter_grades[j])*CREDITS[j];

temp.totalPoints += temp.weighted_scores[j];

}

temp.gpa = (double)temp.totalPoints/NUM_SCORES;

scores.push_back(temp);

}

cout<<setw(4)<<"ID"<<" ";

for(int i=0; i<NUM_SCORES; i++){

cout<<"S"<<(i+1)<<" G"<<(i+1)<<" ";

}

cout<<"Total GPA"<<endl;

for(int i=0; i<NUM_STUDENTS; i++){

cout<<setw(4)<<setfill('0')<<scores[i].idNumber<<" ";

for(int j=0; j<NUM_SCORES; j++){

cout<<scores[i].raw_scores[j]<<" "<<scores[i].letter_grades[j]<<" ";

}

cout<<scores[i].totalPoints<<" "<<scores[i].gpa<<endl;

}

return 0;

}

char getLetterGrade(int score){

if(score>90)

return 'A';

else if(score>80)

return 'B';

else if(score>70)

return 'C';

else if(score>60)

return 'D';

else

return 'F';

}

int gradePoints(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:
use c++ Weighted GPA Calculator2 Many schools factor in the number of credits each course is...
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
  • 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...

  • A student earned grades of Upper A​, Upper F​, Upper A​, Upper D​, and Upper C....

    A student earned grades of Upper A​, Upper F​, Upper A​, Upper D​, and Upper C. Those courses had the corresponding numbers of credit hours 4​, 4​, 2​, 4​, and 3. The grading system assigns quality points to letter grades as​ follows: Aequals​4; Bequals​3; Cequals​2; Dequals​1; Fequals0. Compute the grade point average​ (GPA) as a weighted mean and round the result with two decimal places. If the​ Dean's list requires a GPA of 3.00 or​ greater, did this student make...

  • Task: You want to calculate a student's GPA for a number of classes taken by the...

    Task: You want to calculate a student's GPA for a number of classes taken by the student during a single semester. (In C# (C sharp)) Inputs: 1. the student's name 2. Class names for the classes taken by the student 3. Class letter grade for the classes taken by the student 4. Class credit hours for the classes taken by the student Processing: 1. Accept and process classes until the user indicates they are finished 2. accumulate the number of...

  • A. Create a CollegeCourse class. The class contains fields for the course ID (for example, CIS...

    A. Create a CollegeCourse class. The class contains fields for the course ID (for example, CIS 210), credit hours (for example, 3), and a letter grade (for example, A). Include get and set methods for each field. Create a Student class containing an ID number and an array of five CollegeCourse objects. Create a get and set method for the Student ID number. Also create a get method that returns one of the Student’s CollegeCourses; the method takes an integer...

  • A. Create a CollegeCourse class. The class contains fields for the course ID (for example, CIS...

    A. Create a CollegeCourse class. The class contains fields for the course ID (for example, CIS 210), credit hours (for example, 3), and a letter grade (for example, A). Include get and set methods for each field. Create a Student class containing an ID number and an array of five CollegeCourse objects. Create a get and set method for the Student ID number. Also create a get method that returns one of the Student’s CollegeCourses; the method takes an integer...

  • A. Create a CollegeCourse class. The class contains fields for the course ID (for example, CIS 21...

    A. Create a CollegeCourse class. The class contains fields for the course ID (for example, CIS 210), credit hours (for example, 3), and a letter grade (for example, A). Include get and set methods for each field. Create a Student class containing an ID number and an array of five CollegeCourse objects. Create a get and set method for the Student ID number. Also create a get method that returns one of the Student’s CollegeCourses; the method takes an integer...

  • You will create a class to store information about a student�s courses and calculate their GPA....

    You will create a class to store information about a student�s courses and calculate their GPA. Your GPA is based on the class credits and your grade. Each letter grade is assigned a point value: A = 4 points B = 3 points C = 2 points D = 1 point An A in a 3 unit class is equivalent to 12 grade points (4 for the A times 3 unit class) A C in a 4 unit class is...

  • The following is solved using C++ in Vocareum: In this problem, you will be prompting a...

    The following is solved using C++ in Vocareum: In this problem, you will be prompting a student for grades and credits for courses taken. From that, you will calculate a GPA. This site: http://www.back2college.com/gpa.htm shows you how to calculate a GPA. Keep prompting the student if they want to add more courses. IMPORTANT NOTES! The course name is prompted for, but nothing is done with it. We are just using the grades A, B, C, D, and F so you...

  • C++ program For research purposes and to better help students, the admissions office of your local...

    C++ program For research purposes and to better help students, the admissions office of your local university wants to know how well female and male students perform in certain courses. You receive a file confidentiality, the letter code f is used for female students and m for male students. Every file in the file is unknown. Write a program that computes and outputs the average GPA for both (ECPartIData.txt) that contains female and male student GPAs for certain courses. Due...

  • What is the GPA of a student who gets an A in a 3-credit course, a B in each of two 2-credit courses, a C in a 3-credit course, and a D in a 2-credit course?

    One common system for computing a grade point average (GPA) assigns 4 points to an A, 3 points to a B, 2 points to a C, 1 point to a D, and 0 points to an F. What is the GPA of a student who gets an A in a 3-credit course, a B in each of two 2-credit courses, a C in a 3-credit course, and a D in a 2-credit course?

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