| DESC 391 Assignments Fall 2009 - Assignment 3: Student scores, and reservations |
|
|
| Written by Chitu Okoli and Bilal Abdul Kader | |||||||
| Friday, 19 September 2008 11:35 | |||||||
Page 4 of 5
Assignment 3: Student scores, and reservationsDue: 11:59 pm on Wednesday November 18 The purpose of this assignment is for you to work with arrays, interfaces, and dates in Java. There are two exercises.
1. Display a sorted list of student scores (5%)ConsoleWelcome to the Student Scores Application. Enter number of students to enter: 4 Student 1 last name: Rainer Student 1 first name: Kelly Student 1 score: 95 Student 2 last name: Turban Student 2 first name: Efraim Student 2 score: 92 Student 3 last name: Schmidt Student 3 first name: Doug Student 3 score: 82 Student 4 last name: Sanchez Student 4 first name: Cristal Student 4 score: 93 Rainer, Kelly: 95 Sanchez, Cristal: 93 Schmidt, Doug: 82 Turban, Efraim: 92
Operation· This application accepts the last name, first name, and score for one or more students and stores the results in an array. Then, it prints the students and their scores in alphabetical order by last name. Specifications· Create a class named Student that stores the last name, first name, and score for each student. This class should implement the Comparable interface so the students can be sorted by name. If two students have the same last name, the first name should be used to determine the final sort order. Assume that no two students will have the same first and last name. · Create a StudentScoresApp class to run the program (that is, in its main method). The program should use an array to store the Student objects. Then, it should sort the array prior to printing the student list. · Validate the input so the user can enter only a positive integer for the number of students, the last or first name can’t be an empty string, and the score is an integer from 0 to 100. 2. Calculate reservation totals (5%)ConsoleWelcome to the Reservation Calculator. Enter the arrival month (1-12): 5 Enter the arrival day (1-31): 16 Enter the arrival year: 2005 Enter the departure month (1-12): 5 Enter the departure day (1-31): 18 Enter the departure year: 2005 Arrival Date: Monday, May 16, 2005 Departure Date: Wednesday, May 18, 2005 Price: $115.00 per night Total price: $230.00 for 2 nights Another reservation? (y/n): n
Operation· This application calculates the charges for a stay at a hotel based on the arrival and departure dates. · The application begins by prompting the user for the month, day, and year of the arrival and the departure. · Next, the application displays the arrival date, the departure date, the room rate, the total price, and the number of nights. Specifications· Create a class named Reservation that defines a reservation. This class should contain instance variables for the arrival date and departure date. It should also contain a constant initialized to the nightly rate of $115.00. · The Reservation class should contain a constructor that accepts the arrival and departure dates as parameters of type Date, as well as methods that return the number of nights for the stay (calculated by subtracting the arrival date from the departure date) and the total price (calculated by multiplying the number of nights for the stay by the nightly room rate). This class should also override the toString method to return a string like this: Arrival Date: Monday, May 16, 2005 · The main method for the application class (called ReservationCalculatorApp) should contain a loop that asks the user for the arrival and departure date information, creates a Reservation object, and displays the string returned by the toString method. · Assume valid data is entered. SubmissionTo submit the assignment, do the following:
|
|||||||
| Last Updated on Tuesday, 08 December 2009 11:16 |