Question

In: Computer Science

As a part-time student, you took three courses last semester. Write, run, and test a C++...

As a part-time student, you took three courses last semester. Write, run, and test a C++ program that calculates and displays the numerical grades, the equivalent letter grades and your grade point average (GPA) for the semester. Your program should prompt the user to enter the numerical grade and credit hours for each course. This information should then be displayed in a tabular format. A warning message should be printed if the GPA is less than 2.0 and a congratulatory message if the GPA is 3.5 or above. Recall: A >= 90; 80 <= B < 90; 70 <= C < 80; 60 <= D < 70; F < 60 qualityPoints: A = 4; B = 3; C = 2, D = 1; F =0

Solutions

Expert Solution

#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main() {
    float marks[3],credits[3];
    for(int i=0;i<3;i++) {
        cout<<"Enter your Marks and Credit hours of Subject "<<i<<": ";
            cin>>marks[i]>>credits[i];
    }
        char grades[3];
        float GPA = 0;
        int total_credit = 0;
        for(int i=0;i<3;i++) {
            if(marks[i] >= 90) {
                grades[i] = 'A';
                GPA = GPA+(4*credits[i]);
            }
            else if(marks[i] >= 80) {
                grades[i] = 'B';
                GPA = GPA+(3*credits[i]);
            }
            else if(marks[i] >= 70) {
                grades[i] = 'C';
                GPA = GPA+(2*credits[i]);
            }
            else if(marks[i] >= 60) {
                grades[i] = 'B';
                GPA = GPA+(1*credits[i]);
            }
            else {
                grades[i] = 'F';
                GPA = GPA+(0*credits[i]);
            }
            total_credit = total_credit+credits[i];
        }
        GPA = GPA/total_credit;
        cout<<"Subject\tMarks\tLetter Grade\n";
        for(int i=0;i<3;i++)
            cout<<"Subject"<<(i+1)<<"\t"<<marks[i]<<"\t"<<grades[i]<<"\n";
        cout<<setprecision(2)<<fixed;
        cout<<"The GPA is "<<GPA<<"\n";
        if(GPA < 2.0)
            cout<<"Warning! Your GPA is less than 2.0\n";
        if(GPA >= 3.5)
            cout<<"Congralutions! Your GPA is above 3.5\n";
        return 0;
}

Output

Enter your Marks and Credit hours of Subject 0: 90 5

Enter your Marks and Credit hours of Subject 1: 80 4

Enter your Marks and Credit hours of Subject 2: 95 5

Subject Marks Letter Grade

Subject1 90 A

Subject2 80 B

Subject3 95 A

The GPA is 3.71

Congralutions! Your GPA is above 3.5

Output screenshot


Related Solutions

Java Program Suppose a student was taking 5 different courses last semester. Write a program that...
Java Program Suppose a student was taking 5 different courses last semester. Write a program that (a) asks the student to input his/her name, student ID, marks for these 5 courses, (b) calculate the average, (c) determine the letter grade of each course. (d) record the number of courses whose final letter grade is A+, A, A-, .... , F+, F, F-. (e) Output the following information in a nice format: student name, student ID, listing of marks, the average,...
PLEASE TYPE YOUR ANSWER Imagin you are a student who took microbiology in a semester. how...
PLEASE TYPE YOUR ANSWER Imagin you are a student who took microbiology in a semester. how you explain that What did you learn from your microbiology experiences in this semester that will continue to influence you for many years to come? How did you learn these things? Using specific examples for your statement Such as PPE, Gram stain, HMB, sensitive to penicillin, etc.
PLEASE TYPE YOUR ANSWER Imagin you are a student who took microbiology in a semester. how...
PLEASE TYPE YOUR ANSWER Imagin you are a student who took microbiology in a semester. how you explain that What did you learn from your microbiology experiences in this semester that will continue to influence you for many years to come? How did you learn these things? Using specific examples for your statement Such as PPE, Gram stain, HMB, sensitive to penicillin, etc.
At the beginning of the semester, the amount of time a student waits in line at...
At the beginning of the semester, the amount of time a student waits in line at the campus cafeteria is normally distributed with a mean of five minutes and a standard deviation of 1.5 minutes. If you randomly select 81 students, what is the probability that they have a mean waiting time between 4.7 and 5.8 minutes? Group of answer choices .9641 .718 .0359 .282
You were the top student in your physiology class last semester. For this reason, your professor...
You were the top student in your physiology class last semester. For this reason, your professor has asked that you prepare some lectures for her physiology class this semester. Specifically, she would like you to discuss the similarities and differences between the cardiovascular and respiratory systems, in terms of pressure gradients and fluid flow. A. Explain how you will describe the role of the following structures: the pump and the tubes. B. Explain how you will describe the importance of...
1) You were the top student in your physiology class last semester. For this reason, your...
1) You were the top student in your physiology class last semester. For this reason, your professor has asked that you prepare some lectures for her physiology class this semester. Specifically, she would like you to discuss the similarities and differences between the cardiovascular and respiratory systems, in terms of pressure gradients and fluid flow. Explain how will you describe the role of the following structures: the pump and the tubes. 2) Julia is breathing 14 times per minute, with...
1) You were the top student in your physiology class last semester. For this reason, your...
1) You were the top student in your physiology class last semester. For this reason, your professor has asked that you prepare some lectures for her physiology class this semester. Specifically, she would like you to discuss the similarities and differences between the cardiovascular and respiratory systems, in terms of pressure gradients and fluid flow. Explain how will you describe the role of the following structures: the pump and the tubes. 2) List, compare, and contrast the locations and stimuli...
Last year, those who took the LSAT test a second time score an average of 2.8...
Last year, those who took the LSAT test a second time score an average of 2.8 points higher than the first time. Suppose two independent and identically distributed random samples are drawn from this year’s exam: first-time and second-time LSAT takers. a) Write the hypothesis test where the null is that the difference in scores between first- and second-time LSAT takers has not changed since last year and a two-sided alternative. b) Suppose two independent random samples are drawn. One...
The following information is from Bluff Run Golf Courses. The company runs three courses and the...
The following information is from Bluff Run Golf Courses. The company runs three courses and the July income statement for each course is as follows: BLUFF RUN GOLF COURSES Income Statement Month Ending July 31, 2018 Blue Course   Black Course   Gold Course   Revenues          Greens fees revenue    $62,500    $89,000    $42,900    Outings revenue ? 6,000 29,000 Total revenue $73,100 $95,000 $71,900    Expenses          Landscaping $7,800 $14,200 $6,500 Wages 43,900 ? 32,600 Repairs...
Think about the last time you took a series of tests in a short period of...
Think about the last time you took a series of tests in a short period of time (high school or college finals work here). How did you decide how much time to spend studying for each subject? How might the study of economics help you make that allocation decision in the future? ( Employ marginal analysis as discussed in chapter 1 and the Expanded Discussion under the "Chapter 1" tab.)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT