Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Help getting started with JAVA program that calculates occupancy rate for each floor in hotel room

  1. #1
    Junior Member
    Join Date
    Sep 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help getting started with JAVA program that calculates occupancy rate for each floor in hotel room

    I am new to JAVA and so far, we've only done 3 -4 codes by ourselves and each time, I am pretty sure I failed. What I need help for is this code. How do I get started? Help step by step please.

    Question: Hotel Occupancy

    A hotel's occupancy rate is calculated as follows:

    Occupancy rate = number of rooms occupied / Total number of rooms

    Each floor has its floor occupancy rate, and the hotel also has overall occupancy rate.

    Write a program that calculate the occupancy rate for each floor of a hotel and the overall occupancy rate of the hotel. The program should start by asking for the number of floors (must be no less than 1). A loop should then iterate once for each floor. During each iteration, the loop should ask the user to enter the number of rooms on the floor and the number of them that are occupied (each floor must have at least 10 rooms). The the program will calculate and display the occupancy rate for that floor. After all the iterations, the program should calculate the overall occupancy rate of the hotel. Then program should display the total number of rooms the hotel has, the total number of rooms that are occupied, the total number of rooms that are vacant, and the overall occupancy rate for the hotel.

    For example, suppose a hotel has 2 floors.

    first floor: 100 rooms, 80 occupied. Then occupancy rate is 80%

    second floor: 80 rooms, 52 occupied. The occupancy rate is 65%

    The hotel has 180 rooms together, 132 occupied, 48 vacant, the overall occupancy rate is 73.3%



    Input validation: do not accept a value less than 1 for the number of floors. Do not accept a number less than 10 for the number of rooms on a floor. The number of rooms occupied on a floor cannot be greater than the number of rooms on that floor.


  2. #2
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    585
    My Mood
    Sleepy
    Thanks
    10
    Thanked 87 Times in 80 Posts

    Default Re: Help getting started with JAVA program that calculates occupancy rate for each floor in hotel room

    Ok, what have you done? wher are you stuck? We won't give you ready made code. Post your best attempt and ask specific questions.

  3. #3
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    4,855
    My Mood
    Mellow
    Thanks
    178
    Thanked 631 Times in 618 Posts

    Default Re: Help getting started with JAVA program that calculates occupancy rate for each floor in hotel room

    Start here:

    "The program should start by asking for the number of floors (must be no less than 1) . . . "

    Then follow the assignment's instructions, step by step.

Similar Threads

  1. Find a java program that calculates
    By Zuhairi Abdullah in forum Object Oriented Programming
    Replies: 3
    Last Post: May 9th, 2013, 11:08 AM
  2. Replies: 1
    Last Post: February 10th, 2012, 06:01 AM
  3. Making a program that calculates how many days you lived.
    By shifat96 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 9th, 2012, 11:34 PM
  4. Help with JFrame program that calculates average
    By ePerKar3 in forum AWT / Java Swing
    Replies: 3
    Last Post: November 4th, 2011, 08:48 AM
  5. Simple java program to calculate wall covering of a room
    By parvez07 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: August 22nd, 2009, 03:31 PM