Write a complete program to create HotelRoom class and test class based on the class
diagram above, table below and the following requirements: HotelRoom Class is derived
from Rental and implements Comparable Interface.
The getRentalRate() method from the Rental class will be implemented in the HotelRoom
class to determine and return a room rental rate based on the room types. The room types
and its associated rental rate can be referred in Table 1.
The method toString() will return the information of HotelRoom object.
The HotelRoom class implements compareTo() method from the interface
java.langComparable to compare the room rental rate for two objects of HotelRoom.
Write a test program that creates two HotelRoom objects with any values of the rentalNum,
roomNo and roomTypes.
Display all the information of these two objects including the rental rate comparison result.
Using this online IDE, perform the following.
1. Initialize four (4) variables based on the table below.
Data type Variable NameValue
String firstName Your first name.
String lastName Your last name.
char mi Your middle initial
int faveNumber Your favorite number
String faveCartChar Your favorite cartoon or anime character
2. Create statements that would print an output similar to the sample below. Use '+' to combine words and variable names.
Write a java program that accepts a given n, then create a 2D array with n rows and n columns. Then for each cell the value should be n+row to the power column. For example if we talk of n=5, then array[0][0] =(5+0)0 = 1. Print out all the values in the array created.
Write a Java program to simulate an online store. The program should begin by displaying a list of products and their prices. There should be a minimum of 4 products offered. The program should ask the user to choose a product and then ask the user to enter the quantity they require of that product. The program should then allow the user to keep choosing more products and quantities until they enter something to indicate they want to end the program (e.g. a given number or ‘q’ or ‘exit’). The program should then tell the user the total amount for the products they have selected. Students must use array or arraylist to store the products and their prices.
We want to calculate the total marks of each student of a class in Physics, Chemistry and Mathematics and the average marks of the class. The number of students in the class are entered by the user. Create a class named Marks with data members for roll number, name and marks. Create three other classes inheriting the Marks class, namely Physics, Chemistry and Mathematics, which are used to define marks in individual subject of each student. Roll number of each student will be generated automatically.
1. Exercise 2: Create a class building that has the public member floors,area, and occupants and a method areaperperson()respectively that display the area per person for building. In the main() method create two instance of building called house and office and display the area per person by division of area/occupants
1. Exercises: Write a class Book with three data members BookId, Pages and Price. It also contains the following member function: • The get() method is used to input values • The show() method is used to display values Object Oriented Programming using JAVA Lab Manual – Page 24|193 • The set() method is used to set the values of data members using parameters • The getPrice() method is used to return the value of price
A bagel shop charges 75 cents per bagel for orders of less than a half-dozen bagels and 50 cents per bagel for orders of a half-dozen or more. Write a program that requests the number of bagels ordered and displays the price for each bagel and the total cost. Format the output results with two decimal places
USING IF ELSE CONDITIONAL STATEMENT
Write a JAVA program that will input Employee Name, Rate per hour, No. of hours worked
and will compute the daily wage of an employee. If the number of hours worked exceeds
eight hours add 30% to each excess hour as overtime rate.
Formula: Daily Wage = Rate per hour * No. of hours worked + OT pay
IF ELSE CONDITIONAL STATEMENT
Write a JAVA program that will input the following data: Student Name, Average, Tuition Fee
and output Total Tuition Fee.
Formula: Total Tuition Fee = Tuition Fee – Discount
If average is: 95 – 100 100% discount
90 – 94 25%
85 – 89 10%
84 and below no discount