Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

***Note***: This need to be done with JAVA and it needs a psudeo code as well, please make sure the indentation is correct and standard,thank

***Note***: This need to be done with JAVA and it needs a psudeo code as well, please make sure the indentation is correct and standard,thank you!

Based on Count Controlled Loops (use FOR LOOPS)

Notes: You must FOR LOOPS where indicated in the first program you will NOT need nested for loops. The table is EXAMPLE USER INPUT for you to use to test your program, do NOT try to print the input table, just the output below.

Program #1: Hotel Occupancy: Write a program that calculates the occupancy rate for a hotel. The program should start by asking the user how many floors the hotel has. A for loop should then iterate once for each floor. In each iteration of the for loop, the program should ask the user for the number of rooms of the floor and how many of them are occupied. After all of the iterations are complete the program should display how many rooms the hotel has, how many of them are occupied, and the percentage of rooms that are occupied.

It is traditional that most hotels do not have a 13th floor. The for loop in this program should skip the entire thirteenth loop iteration.

Input validation: Do not accept a value of less than one for the number of floors. Do not accept a value of less than 10 for the number of rooms on a floor. Do not accept a value for occupied that is greater than rooms.

EXAMPLE INPUT TO USE FOR TESTING (just an example your program should work for all different inputs):

If the Number of Floors in the Hotel: 16

And the user to INPUT the following information for total rooms and occupied rooms:

Floor #

Total Rooms

Occupied Rooms

1

200

180

2

170

100

3

50

20

4

125

125

5

100

80

6

200

80

7

80

40

8

90

45

9

95

0

10

115

103

11

125

17

12

140

128

14

130

129

15

100

99

16

60

24

The output of your program for the above example should be (do NOT print the above chart!):

The Hotel has 1780 Total Rooms.

1170 of the Rooms are Occupied.

66 % of the Rooms are Occupied.

Program #2: Pennies: For the first day worked a person earns $1.00 for the entire day. For the second day worked the persons daily pay is doubled to $2.00. For the third day worked the persons daily pay is doubled again to $4.00. For each consecutive day a person works their daily pay is doubled in this way.

Write a program that asks a user to enter the number of days they worked and then calculates the pay they earned for each day along with the total pay they earned for all of the days. The program output should be the pay for each day and the total pay earned for all the days.

Input Validation: Do not let the user enter a number of days that is less than 1. Use a loop to prompt them to enter another number for the number of days if they enter a number that is less than 1.

Make sure and format your output.

Example: This would be the output for a person who worked 4 days

Pay for Day 1: $1.00 Pay for Day 2: $2.00 Pay for Day 3: $4.00 Pay for Day 4: $8.00

TOTAL PAY FOR 4 DAYS: $15.00

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Genetic Databases

Authors: Martin J. Bishop

1st Edition

ISBN: 0121016250, 978-0121016258

More Books

Students also viewed these Databases questions