Floor Rooms Occupied Occupancy Rate Room Price 1 20 14 70.0% 2 33 18 54.5% 3 33 12 36.4% $ 168.99 $ 152.99 $ 152.99 Revenue $ 2,365.86 $ 2,753.82 4 33 15 45.5% $ 152.99 $ 1,835.88 $ 2,294.85 5 16 8 50.0% $ 254.99 $ 2,039.92

Programming with Microsoft Visual Basic 2017
8th Edition
ISBN:9781337102124
Author:Diane Zak
Publisher:Diane Zak
Chapter4: The Selection Structure
Section: Chapter Questions
Problem 1MQ6
icon
Related questions
Question

//Main.java

public class Main{
    public static void main(String[] args) {

        final int NUM_FLOORS = 5;
        Hotel[] floor_number = new Hotel[NUM_FLOORS];

        floor_number[0] = new Hotel(20, 14, 168.99); 
        floor_number[1] = new Hotel(33, 18, 152.99); 
        floor_number[2] = new Hotel(33, 12, 152.99); 
        floor_number[3] = new Hotel(33, 15, 152.99); 
        floor_number[4] = new Hotel(16, 8, 254.99);  

        System.out.printf("%-8s%-10s%-12s%-18s%-15s     %-10s\n", "Floor", "Rooms", "Occupied", "Occupancy Rate", "Room Price", "Revenue");

        for (int i = 0; i < floor_number.length; i++) {
            Hotel current_hotel_number = floor_number[i];

            int rooms = current_hotel_number.getRooms();
            int occupiedRooms = current_hotel_number.getOccupiedRooms();
            double roomCost = current_hotel_number.getRoomCost();
            double occupancyRate = current_hotel_number.getFloorOccupancyRate();
            double revenue = current_hotel_number.getFloorRevenue();

            System.out.printf("  %-8d%-10d %-12d  %-17.1f%% $%-14.2f$%-10.2f%n", i + 1, rooms, occupiedRooms, occupancyRate, roomCost, revenue);        
            }
    }
}

 

 

 

//Hotel.java

public class Hotel
{
private int rooms ;
private int occRooms ;
private double roomCost ;

public Hotel()
{
rooms = 0 ;
occRooms = 0 ;
roomCost = 0.0 ;
}

public Hotel(int rms, int occRms, double rmCst)
{
rooms = rms ;
occRooms = occRms ;
roomCost = rmCst ;
}

public Hotel(String rms, String occRms, String rmCst)
{
rooms = Integer.parseInt(rms) ;
occRooms = Integer.parseInt(occRms) ;
roomCost = Double.parseDouble(rmCst) ;
}

public void setRooms(int rms)
{
rooms = rms ;
}

public void setRooms(String rms)
{
rooms = Integer.parseInt(rms) ;
}

public void setOccupiedRooms(int occRms)
{
occRooms = occRms ;
}

public void setOccupiedRooms(String occRms)
{
occRooms = Integer.parseInt(occRms) ;
}

public void setRoomCost(double rmCst)
{
roomCost = rmCst ;
}

public void setRoomCost(String rmCst)
{
roomCost = Double.parseDouble(rmCst) ;
}

public int getRooms()
{
return rooms ;
}

public int getOccupiedRooms()
{
return occRooms ;
}

public double getRoomCost()
{
return roomCost ;
}

public double getFloorRevenue()
{
return occRooms * roomCost ;
}

public double getFloorOccupancyRate()
{
return ((double)occRooms / (double)rooms) * 100 ;
}
}

 

 

I can not find a way to get the output to be correctly formatted. I attached an attachment for the correct format can you please help me?

Floor
Rooms
Occupied
Occupancy Rate
Room Price
1
20
14
70.0%
2
33
18
54.5%
3
33
12
36.4%
$ 168.99
$ 152.99
$ 152.99
Revenue
$ 2,365.86
$ 2,753.82
4
33
15
45.5%
$ 152.99
$ 1,835.88
$ 2,294.85
5
16
8
50.0%
$ 254.99
$ 2,039.92
Transcribed Image Text:Floor Rooms Occupied Occupancy Rate Room Price 1 20 14 70.0% 2 33 18 54.5% 3 33 12 36.4% $ 168.99 $ 152.99 $ 152.99 Revenue $ 2,365.86 $ 2,753.82 4 33 15 45.5% $ 152.99 $ 1,835.88 $ 2,294.85 5 16 8 50.0% $ 254.99 $ 2,039.92
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
New Perspectives on HTML5, CSS3, and JavaScript
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:
9781305503922
Author:
Patrick M. Carey
Publisher:
Cengage Learning
Oracle 12c: SQL
Oracle 12c: SQL
Computer Science
ISBN:
9781305251038
Author:
Joan Casteel
Publisher:
Cengage Learning
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781305627482
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Principles of Information Systems (MindTap Course…
Principles of Information Systems (MindTap Course…
Computer Science
ISBN:
9781305971776
Author:
Ralph Stair, George Reynolds
Publisher:
Cengage Learning