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 program that translates a letter grade into a number grade. Letter grades are A,...
Write a program that translates a letter grade into a number grade. Letter grades are A, B, C, D, and F, possibly followed by + or -. Their numeric values are 4, 3, 2, 1 and 0. There is no F+ or F-. A “+” increases the numeric value by 0.3, a “–“ decreases it by 0.3. However, an A+ has value 4.0.4 pts Enter a Letter grade: B- The numeric value is 2.7 Your code with comments A screenshot...
Write a C++ program named, myGrade.cpp, that calculates a letter grade for a student of this...
Write a C++ program named, myGrade.cpp, that calculates a letter grade for a student of this course (CSC100 online) based on three user inputs. This program should begin by printing the title of the application (program) and a brief description of what it does. (Note: this is NOT the same as the program prolog: a prolog is much more detailed, has required elements, and is intended for other programmers reading the cpp file. The title and description displayed by the...
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...
Program 5A: Determine which student has the highest grade Write a Java program that determines which...
Program 5A: Determine which student has the highest grade Write a Java program that determines which student has the highest grade. You will ask the user to enter the number of students. Then you will ask for each student and their grade. You will output the name and grade of the student with the highest grade. You will NOT use an array for this assignment. Call your class Program5A, so your filename will be Program5A.java. It is essential for grading...
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 program that counts the letters in a given string and then display the letter...
Write a program that counts the letters in a given string and then display the letter count in order from high to low. The program should: Display a message stating its goal Prompt the user to enter a string input Count the letters in the string (hint: use dictionaries) Display the letter count in order from high to low (sort your letter count) For example, for the input Google the output should be G - 2 O - 2 E...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT