a. Sammys Seashore Supplies rents beach equipment such as kayaks, canoes, beach chairs, and umbrellas to tourists.

Question:

a. Sammy’s Seashore Supplies rents beach equipment such as kayaks, canoes, beach chairs, and umbrellas to tourists. In Chapter 2, you wrote an application that prompts the user for the number of minutes a piece of sports equipment was rented, displays the company motto with a border, and displays the price for the rental. Now modify the program so that the main() method contains only three executable statements that each call a method as follows:

  • The first executable statement calls a method that prompts the user for the rental time in minutes and returns the value to the main() method.
  • The second executable statement calls a method that displays the company motto with the border.
  • The last executable statement passes the number of minutes to a method that computes the hours, extra minutes, and price for the rental, and then displays all the details. Save the file as Sammys RentalPriceWithMethods.java.

b. Create a class to hold Rental data for Sammy’s Seashore Supplies. The class contains:

  • Two public final static fields that hold the number of minutes in an hour and the hourly rental rate ($40)
  • Four private fields that hold a contract number, number of hours for the rental, number of minutes over an hour, and the price. The contract number is stored as a String because Sammy plans to assign contract numbers such as K681.
  • Two public set methods. One sets the contract number (setContractNumber()). The other is named setHoursAndMinutes(), and it accepts the number of minutes for the rental and then sets the hours, extra minutes over an hour, and the total price. Recall from Chapter 2 that the price is $40 per hour plus $1 for every extra minute. 
  • Four public get methods that return the values in the four nonstatic fields. Save the file as Rental.java.

c. Use the SammysRentalPriceWithMethods class you created in Step 2a as a starting point for a program that demonstrates the Rental class you created in Step 2b, but make the following changes:

  • You already have a method that gets a number of minutes from a user; now add a method that gets a contract number. The main() method should declare a Rental object, call the two data entry methods, and use their returned values to set the fields in the Rental object.
  • From the SammysRentalPriceWithMethods class, call the RentalDemo method that displays the company motto with the border. The method is accessible because it is public, but you must fully qualify the name because it is in another class.
  • Revise the method that displays the rental details so that it accepts the newly created Rental object. The method should display the contract number, and it still should display the hours and minutes, the hourly rate, and the total price. Save the program as RentalDemo.java.
Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question

Java Programming

ISBN: 978-1337397070

9th edition

Authors: Joyce Farrell

Question Posted: