Assigned:
Thursday, Sep 10, 2015
Due: Tuesday, September 22, 11:55 PM
Description
In this assignment, you will create a program that calculates the total scores and difference of the UNC and Duke Football team.
-- Create a Java Project in Eclipse named Program1.
-- Create a class in your project named FootballScoreboard.
-- This should also create the file FootballScoreboard.java.
-- Create a main method in your FootballScoreboard.java file.
Once you have created the main method, follow these instructions to create the program. Please note that proper spelling and Java naming conventions are important to receive full credit.
1.) Print the welcome message to the
user. Make sure your message contains the word “welcome” and “football” in it.
2.) Using
Scanner, ask the user how many points the Tar Heels scored in each quarter.
Store these 4 inputs in integer variables called uncQuarter1, uncQuarter2, uncQuarter3, uncQuarter4.
3.) Using
Scanner, ask the user how many points the Blue Devils scored in each quarter.
Store these 4 inputs in integer variables called dukeQuarter1, dukeQuarter2, dukeQuarter3, dukeQuarter4.
4.) Calculate
the total points scored by each team and store UNC’s total points in uncScore and store Duke’s total points in dukeScore.
5.) Print
the total points scored by both teams. Your message should contain the word
“total”.
6.) Calculate
the difference in points between the two teams and store it in a variable
called difference. Note: We want only
positive numbers for the difference. So, you can either compute the absolute
value or multiply your difference by “-1” if the difference is negative.
7.) Using
an if-else statement, print which team won the game by how much. There are three possible
scenarios:
a.
if
uncScore is
more than dukeScore,
print “UNC won the game!” along with the difference.
b.
If uncScore is less than dukeScore print “Duke won the
game.” along with the difference.
c.
Otherwise, if uncScore is equal to dukeScore print
“It was a tie.” You do not
need to print difference.
Run your program to test that it works. Don't forget to change the header at the top of the program to write your name and any other information about the program.
*Note: Do not worry about the user inputting negative numbers, or the program displaying this. We will worry about them in the later assignments.
The output of your program should look similar to this:
Welcome to the Football Scoreboard!
How many points did UNC score in each quarter?
25
32
68
21
How many points did Duke score in each quarter?
12
34
19
45
UNC’s total score = 146
Duke’s total score = 110
UNC won the game! The difference in points was 36.
Grading
● 5 points Your program contains a proper header.
● 15 points Your FootballScoreboard class contains a working main method.
● 5 points Your program contains a welcome message to the user.
● 10 points Your program contains a print statement asking for UNC’s points in each quarter.
● 10 points Your program contains a print statement asking for Duke’s points in each quarter.
● 15 points Your program checks for all three scenarios in #7 above.
● 15 points Your program calculates the difference in points and the total scores of both teams.
● 5 points Your program prints the total scores of both teams
● 10 points Your program uses the variables uncScore, dukeScore and difference.
● 10 points Your program prints which team won or whether it was a tie.
How to submit the assignment
● A file named youronyen_assignment1.zip, where youronyen is your onyen. The .zip file should include your whole project from Eclipse. Your java file should have the appropriate header. Follow these instructions to create youronyen_assignment1.zip
● Check your zipped file here: zipchecker
● Submit (Send File) youronyen_assignment1.zip on Sakai by 11:55PM on Tuesday, September 22.
● If you do not follow these instructions you will not get credit for this assignment. Please let us know if you are having any problems with the assignment submission.