I already did inútil number two but i do know what to do after, it is to make a gpa Write a program that calculates the effect that various possible grades in CS201 will have on the user's GPA
Use Console input to ask the user for his or her present GPA and the number of total units he or she has taken. Cast these to a Double and an Integer. For each of the above variables, ask the user repeatedly until s/he enters reasonable values. A GPA cannot be greater than 4.0 nor less than 0.0, and the number of units completed can't be less than 0. However, it is OK if the program breaks when the user enters input that cannot be parsed to the numeric types (for example, if user inputs age a). For simplicity, you may assume the user is not taking any other classes this term.
Note that CS201 is a 5 unit class. Use a variable or constant for this value so that you could easily change it if you wanted to apply this program to another class.
The new GPA is calculated this way: ((present GPA * existing units) + (new units * grade)) / (existing units + new units). Use a loop to find the effect on the student's GPA for each possible grade in CS201. A corresponds to 4 grade points, A- to 3.7, B+ to 3.3, B to 3, B- to 2.7, C+ to 2.3, and C to 2.0. Do not use the letter grades, only the numeric values. Use a while or do...while loop containing if/else code that decrements the grade by 0.3 if it was 4.0, 3.3, 3.0, or 2.3 or decrements it by 0.4 if it was 3.7 or 2.7.
You will need to use Math.abs() in the loop test. Due to the imprecision of floating point types, you will not get correct results if you simply test whether a grade is, for example, equal to 3.0. See lecture 5. Think carefully about the test in the while or do...while loop. The loop should break after the output is shown for a grade that is near 2.0, which is a double. For each possible grade, show the grade, the new GPA, and the change between the old and new GPAs.
Aucun commentaire:
Enregistrer un commentaire