Question: Using java, this Exercise has 3 classes: UseMotelRoom, MotelRoom, and MotelSuite. The UseMotelRoom class has been created for you. Finish the Class named MotelRoom that
Using java, this Exercise has 3 classes: UseMotelRoom, MotelRoom, and MotelSuite. The UseMotelRoom class has been created for you. Finish the Class named MotelRoom that includes an integer field for the room number and a double field for the nightly rental rate. Include get methods for these fields and a constructor that requires an integer argument representing the room number. The constructor sets the room rate based on the room number: rooms numbered 299 and below are $69.95 per night, and others are $89.95 per night. Create an extended class named MotelSuite whose constructor requires a room number and adds a $35 surcharge to the regular hotel room rate, which again is based on the room number.
THE ALREADY CREATED CLASS CODE:
/* * put header information here */
import java.util.*; public class UseMotelRoom {
public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("Please enter the Motel room number:"); int roomNumber = input.nextInt(); System.out.println("Please enter the Suite number:"); int suiteNumber = input.nextInt(); MotelRoom motelRoom = new MotelRoom(roomNumber); MotelSuite motelSuite = new MotelSuite(suiteNumber); System.out.printf("The motel room %d has a rate of $%.2f while " + "the suite %d has a rate of $%.2f",motelRoom.getRoomNumber(), motelRoom.getRentalRate(),motelSuite.getRoomNumber(),motelSuite.getRentalRate());
} // end main method
} //end class UseMotelRoom
//************************************************************* //***** MotelRoom class is below this box ** //************************************************************* class MotelRoom {
// create the MotelRoom class code
} //end of MotelRoom
//************************************************************* //**** MotelSuite Class is below this box ** //*************************************************************
class MotelSuite {
// create the MotelSuite class code
} //end of MotelSuite
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
