Question: Write a class definition for a subclass suite92. A suite92 is a hotelroom92, but use the fact that a suite92 is a hotelroom92 with extras

Write a class definition for a subclass suite92. A suite92 "is a" hotelroom92, but use the fact that a suite92 is a hotelroom92 with extras (that cost $30.00 more). The extra $30.00 is the only difference you have to code. Write the constructor for suite92, calling the hotelroom92 constructor to initialize the two inherited data fields and then you add the $30 on to the roomrate. The rest of the suite92 class would be the same as a hotelroom92. The hotelroom92 class definition and the main ex92c for the hotelroom92 are attached. 2c. Add a suite92 object to main ex92c with room number 475 by running the constructor. Use the inherited get methods to print the room number and room rate (like the hotelroom92 object).

Hotelroom class:

public class hotelroom92 { protected int roomnum; protected double roomrate; public hotelroom92(int n) { roomnum = n; if (roomnum <= 299) roomrate = 69.95; else roomrate = 89.95; } public int getroomnum() { return roomnum; } public double getroomrate() { return roomrate; } } 

Hotel Room main method:

public class ex92c { public static void main(String[] args) { hotelroom92 h = new hotelroom92(375); System.out.println("Hotel Room " + h.getroomnum() + " " + h.getroomrate()); } } 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!