Question

In: Computer Science

Write a c++ program that given a set of letter grade/credit hour combiniation, determines the grade...

Write a c++ program that given a set of letter grade/credit hour combiniation, determines the grade point average (GPA) Each A is worth 4 points. Each B is worth 3 points. Each C is worth 2 points. Each D is worth 1 point, and Each F is worth 0 points. The total quality points earned is the sum of the product of letter grade points and associated course credit hours. The GPA is the quotient of the quality points divided by the total number of credit hours. Gather the student's first name, last name, number of coursed taken. Then for each course gathered the letter grade and number of credit hours for the course. Compute and display the student's GPA with 2 places after the decimal point.

Solutions

Expert Solution

#include <iostream>
#include <iomanip> // std::setprecision
using namespace std;

int main()
{
   //Declaring variables
string fname,lname;
int number_Of_courses;
double GPA=0.0;
int quality_points=0,tot_credit_hrs=0,letterGradePts=0;

//Setting the precision to two decimal points
std::cout << std::setprecision(2) << std::fixed;
  
//getting the firstname entered by the user
cout<<"Enter the First name:";
cin>>fname;

//getting the lastname entered by the user   
cout<<"Enter the Last name:";
cin>>lname;

//getting the no of courses taken entered by the user
cout<<"Enter the no of courses taken :";
cin>>number_Of_courses;

//Creating the arrays which hold letter grades and credit hours
char letterGrade[number_Of_courses];
int credit_hrs[number_Of_courses];


//Getting the letter grades and credit hours
for(int i=0;i<number_Of_courses;i++)
{
    cout<<"Enter the letter grade for course#"<<i+1<<":";
    cin>>letterGrade[i];
   
    cout<<"Enter the credit hours :";
    cin>>credit_hrs[i];
   
   }
     
   //calculating the quality Points and total credit hours
   for(int i=0;i<number_Of_courses;i++)
   {
      if(letterGrade[i]=='A')
      letterGradePts=4;
      else if(letterGrade[i]=='B')
      letterGradePts=3;
      else if(letterGrade[i]=='C')
      letterGradePts=2;
      else if(letterGrade[i]=='D')
      letterGradePts=1;
      else if(letterGrade[i]=='F')
      letterGradePts=0;
     
      quality_points+=letterGradePts*credit_hrs[i];
     
      tot_credit_hrs+=credit_hrs[i];
     
   }
     
   //Calculating GPA
   GPA=(double)quality_points/tot_credit_hrs;
     
   //Displaying the Student GPA
   cout<<"The Student GPA is :"<<GPA<<endl;
     
return 0;
}

____________

Output:

_________________Thank You


Related Solutions

write a Java program Write a program to assign a letter grade according to the following...
write a Java program Write a program to assign a letter grade according to the following scheme: A: total score >= 90 B: 80 <= total score < 90 C: 70 <= total score < 80 D: 60 <= total score < 70 F: total score < 60 Output - the student's total score (float, 2 decimals) and letter grade Testing - test your program with the following input data: test1 = 95; test2 = 80; final = 90; assignments...
Lab 3.4 Write a program that determines a student’s grade. The student will enter a grade...
Lab 3.4 Write a program that determines a student’s grade. The student will enter a grade and the program will determine if that grade is an A, B, C, D, or E. The student can only enter number 0-100. A = 90-100 B = 80-89 C = 70-79 D= 60-69 E = 59 or less Save the file as Lab3.4 and submit the file. Use https://repl.it/ THIS LANGUAGE IS PYTHON Thank you :)
Write a program that determines a student’s grade. The program will read three types of scores...
Write a program that determines a student’s grade. The program will read three types of scores (quiz, mid-term, and final scores) and determine the grade based on the following rules: -if the average score =90% =>grade=A -if the average score >= 70% and <90% => grade=B -if the average score>=50% and <70% =>grade=C -if the average score<50% =>grade=F Using Switch Statement Need to code to be simple to understand. No pointers should be used
Write a C program that, given a file named Program_2.dat as input, determines and prints the...
Write a C program that, given a file named Program_2.dat as input, determines and prints the following information: The number of characters in the file. The number of uppercase letters in the file. The number of lowercase letters in the file. The number of words in the file. The number of lines in the file. Your program should assume that the input file, Program_2.dat, may contain any text whatsoever, and that text might be, or might not be, the excerpt...
PYTHON PROGRAM: Write a program that determines the day of the week for any given calendar...
PYTHON PROGRAM: Write a program that determines the day of the week for any given calendar date after January 1, 1900, which was a Monday. This program will need to account for leap years, which occur in every year that is divisible by 4, except for years that are divisible by 100 but are not divisible by 400. For example, 1900 was not a leap year, but 2000 was a leap year.
C++ UML is required for this program. Partial credit will be given in the program if...
C++ UML is required for this program. Partial credit will be given in the program if you comment your code and I can see you had the right idea even if it is not working correctly. It is better to write comments for parts of the program you cannot figure out than to write nothing at all. Read the directions for the program carefully before starting. Make sure and ask if the directions are unclear. The Rent-a-Pig company rents guinea...
Write a C program that calculates a student grade in the C Programming Class. Ask the...
Write a C program that calculates a student grade in the C Programming Class. Ask the user to enter the grades for each one of the assignments completed in class: Quiz #1 - 25 points Quiz #2 - 50 points Quiz #3 - 30 points Project #1 - 100 points Project #2 - 100 points Final Test - 100 points The total of the quizzes count for a 30% of the total grade, the total of the projects counts for...
write a c++ program an expression that determines if an integer, n is a negative four...
write a c++ program an expression that determines if an integer, n is a negative four digit number. write a c++ program an expression that determines if a string, wd, equals "so" ignoring case.
(c++ programming) We want to assign a letter grade based on the following scaling chart. Write...
(c++ programming) We want to assign a letter grade based on the following scaling chart. Write a program to do it Enter your score: 85 Your grade is a “B” 0-------------------60---------70-------------80-----------90-------------100 F D C B A MUST use nested if-else statements.
*** In C++ Write a program that converts from 24-hour notation to 12-hour notation. For example,...
*** In C++ Write a program that converts from 24-hour notation to 12-hour notation. For example, it should convert 14:25 to 2:25 P.M. The input is given as two integers. This is what I have so far. The program runs for correct input values, but I cannot figure out how to accommodate for hours > 23 and minutes > 59, or negative values. My code is below: // Writing a program that converts from 24-hour notation to 12-hour notation.// #include...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT