Write a C++ (use cout and cin )program that calculates a student's GPA. Ask the user to enter grade and also the credit hours of the course in a loop until user enter “N” or “n”. Earned points in that course becomes Grade point * credit hours i.e., Earned points = Grade point*credit hours Grade points of each grade are as follows Grade Grade Points A = 4 B = 3 C = 2 D = 1 F = 0
Control structures
Control structures are block of statements that analyze the value of variables and determine the flow of execution based on those values. When a program is running, the CPU executes the code line by line. After sometime, the program reaches the point where it has to make a decision on whether it has to go to another part of the code or repeat execution of certain part of the code. These results affect the flow of the program's code and these are called control structures.
Switch Statement
The switch statement is a key feature that is used by the programmers a lot in the world of programming and coding, as well as in information technology in general. The switch statement is a selection control mechanism that allows the variable value to change the order of the individual statements in the software execution via search.
Write a C++ (use cout and cin )program that calculates a student's GPA. Ask the user to enter grade and also the credit hours of the course in a loop until user enter “N” or “n”. Earned points in that course becomes Grade point * credit hours i.e.,
Earned points = Grade point*credit hours
Grade points of each grade are as follows
Grade |
Grade Points |
A = |
4 |
B = |
3 |
C = |
2 |
D = |
1 |
F = |
0 |
Example:
You got “A” grade in
Similarly if you get “C” grade in another subject e.g., Computer Fundamentals and the credit hours are also 3 here. Now earned grade points = 2*3=6
If you get “B” grade in Circuit and Systems theory and the credit hours are 3. So your earned grade points=3*3=9
Now your GPA = (12+6+9) / 9 = 3
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)