CPSC 220 — Computer Programming — Spring 2023

Programming assignment #1

Due: Wednesday, Feb. 1st, midnight

GPA Calculator - part 1

Your first assignment will be to write a very simple Java program that can calculate a student's GPA for one semester. The program should assume that the student is taking exactly five classes during the semester, no more and no less.

When run, the program should prompt the user for the number of credits and the grade in each of their classes. It will print out the semester's GPA to two decimal places. After this, it may also print out one of the following three messages if the GPA falls in the appropriate range:

You made the President's List!

or

You made the Dean's List!

or

You will be placed on academic probation. :'(

(Hint: look in the UMW catalog, or search the UMW website, to find the GPA thresholds for these three designations.)

Note that if the GPA doesn't fall into one of these special ranges, no additional message will be printed. Note also that no more than one of these messages should be printed (e.g., if the GPA qualifies for the President's List, only the President's List message should appear, not also the Dean's List message.)

When run, the output of the program should look as follows (note the red text is what the user types as the program executes, not what the program itself outputs):

How many credits was your first class? 3
What grade did you get? C+
How many credits was your second class? 3
What grade did you get? B-
How many credits was your third class? 4
What grade did you get? B+
How many credits was your fourth class? 3
What grade did you get? A-
How many credits was your fifth class? 1
What grade did you get? A
Your GPA is 3.09.

Another example would be:

How many credits was your first class? 3
What grade did you get? A
How many credits was your second class? 4
What grade did you get? A
How many credits was your third class? 3
What grade did you get? A
How many credits was your fourth class? 3
What grade did you get? A
How many credits was your fifth class? 3
What grade did you get? A
Your GPA is 4.00.
You made the President's List!

Getting started

Assuming you've completed the NetBeans setup homework, you should create a new NetBeans project, choose the "Java with Ant" category, and choose the "Java Application" project type. Call your project "Gpa1" (that's the number one, not the letter ell) and make sure that "Create Main Class" is checked. The other defaults should be okay.

(Please call your project exactly "Gpa1". Please do not change this name, or get creative or cool, or personalize it, or change the capitalization, or misspell it, or use any other name than the four characters G, p, a, and 1, in that order. Thanks.)

Before beginning to work on the program, double-check that line 5 or so of your source file reads exactly "package gpa1;". Double check every letter of that line.

Remember to add this as the first line of your main() function:

java.util.Scanner input = new java.util.Scanner(System.in);

Add the rest of your code for this program immediately below that line, but above the closing curly brace for the main() function (this is the second-to-the-bottom curly brace in the file, which will initially be on line 19 or so.)

Implementation specifics

This program does not need, and should not use, a loop. Instead, it should repetitively use multiple input, output, and calculation statements to produce the desired result.

"But waaah this is so easy..."

For those of you who are seasoned programmers: yes, you're right, this is a very, very simple program. This assignment is not indicative of what most of our semester will entail. Keep in mind that there are those in the class who are either new-ish to programming and/or brand new to Java. They need to learn the ropes so they get up to the same level you are. That will take about a month. I promise you, the programming assignments will get much more challenging and more interesting after that.

Turning it in

Send an email to CPSC220HomeworkSubmission@gmail.com by the deadline with your .java file attached (double-check it's actually attached!!) and with subject line "CPSC 220 program #1 turn-in". Note carefully that I'm asking for your .java file. Here are some things I'm not asking for:

You will know you're submitting the right thing if (1) it is a single file, (2) it ends with a .java extension, and (3) if you open it up in a plain old editor (like Notepad, WordPad, or TextEdit) and it looks like Java source code.

Help!

Got questions? Come to office hours or send email (with subject line "CPSC 220 program #1 help!!") or else go see Bella or Noah!