Question: a. Sunshine Seashore Supplies rents beach equipment to tourists. In previous chapters, you have developed a Rental class that holds equipment rental information. Now modify

a. Sunshine Seashore Supplies rents beach equipment to tourists. In previous chapters, you have developed a Rental class that holds equipment rental information. Now modify the Rental class as follows:
❯❯Modify the method that sets the contract number in the Rental class so that if the argument passed to the method is not a four-character String that starts with a letter followed by three digits, then the contract number is forced to A000. If the initial letter in the contract number is not uppercase, force it to be so.
❯❯Add a contact phone number field to the Rental class.
❯❯Add a set method for the contact phone number field in the Rental class. Whether the user enters all digits or any combination of digits, spaces, dashes, dots, or parentheses for a phone number, store it as all digits. (Assume a phone number is 10 digits and does not require a leading digit that might be needed when dialing.) For example, if the user enters (920) 872-9182, store the phone number as 9208729182. If the user enters a number with fewer or more than 10 digits, store the number as 0000000000.
❯❯Add a get method for the phone number field. The get method returns the phone number as a String constructed as follows: parentheses surround a three-digit area code, followed by a space, followed by the three-digit phone exchange, followed by a hyphen, followed by the last four digits of the phone number. Save the file as Rental.java.
b. Create a RentalDemo application that does the following:
❯❯Prompts the user for a contract number and number of minutes for three Rental objects.
❯❯Prompts the user for and retrieves a contact phone number for each of the Rental objects.
❯❯Displays the contract number and contact phone number for each Rental. Save the file as RentalDemo.java.

Step by Step Solution

3.31 Rating (169 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

a b class R... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Java Programming Questions!