Details:
Create a new project in eclipse as a before. Name this one again using
your first initial and last name and then Lab2. So mine would be
jsantoreLab2
Again add a new class to your project in eclipse. Call this class Lab2
Your class should do the following. (your main job is to figure our how
to write the code to do this.) I encourage you to look at code listing
2-27 on pages 89-90 of your book (Payroll.java from the Chapter 02
folder in the sourcecode from the cd in the back of you book). This
program is quite similar, though not exactly the same and the one you
will do.
This lab will be a simple GPA calculator for a student with three classes.
- You should first ask the student for his/her name.
- Now you need to ask three times for the following two pieces of information
- How many credits is the class worth. (to make life easy for yourself read this in as a float or a double)
- what was the grade points for the class (this should be read in as a float or a double)
- The user should enter
something from 0.0 to 4.0 for this answer. Lets assume the user will
since I'll be your user for grading purposes.
- After you have read in all three of the grade point and credit
pairs, you need to calculate the gpa. Recall that a GPA is counted by
multiplying the number of credits for a course by the grade points for
the course. Adding that to the product of the credits and grade points
for all other courses and then deviding by the total number of credits.
- Print out the person's name and GPA for this semester.
Hint: you will need at least 7 unique variables for this lab, one for
the name, then one for each class's credits (for a total of three more)
and one the grade points for each class(three classes so you need three
more here)
your design might also need an eight variable for the output string.
An example run on the program might look like this:
What is your name: John
How many credits is your first class worth: 4
What was your grade in that class: 3.0
How many credits is your second class worth: 3
What was your grade in that class: 4.0
How many credits is your third class worth: 3
What was your grade in that class: 3.3
John your GPA for this semester is 3.39
If you are using Payroll.java as a guide for this project as I
suggested earlier, be aware that this project is slightly longer than
that one. Expect to have anywhere from 1.5 to 2 times the code of that
project.
Submitting:
again zip up your project folder and submit it to me by email.
Make sure that your submitted zip file contains your first initial and last name as part of the zip file name.