Question: The java program you will create is to allow a user to enter the type of an apartment they would like (basement, 1st floor, 2nd
The java program you will create is to allow a user to enter the type of an apartment they would like (basement, 1st floor, 2nd floor, etc) and you will write the code that will prompt them for the floor they want to rent and you will print out the number of apartments available for that type of apartment. You will use the 2 parallel arrays, Apts[] ={5, 3,1,2} and Rents[] ={200, 350, 450, 600} ; Apts[] represents the number of apartments available for each floor apts[0] = 5, which means there are 5 apartments available on the 0 (basement) level. Apts[1] = 3 which means there are 3 apartments available on the 1st floor, etc. Rents[] represents the rent for each of these apartments: Rents[0] = 200 which means a basement apartment costs 200 dollars to rent.
First Goal:
Your user should be allowed to enter the amount of money they have to spend, ie : $550 and you have to determine which apartments they can rent for that amount of money.
Example: If the user enters $550, then you should output that they are able to rent from the 2nd floor and below.
Accomplish this in a method qualify() which will return the highest floor available at the price entered by the user.
Second Goal:
Your user should be allowed to enter the floor they decide and you output the number of apartments available at that floor.
Example: If the user enters the 2nd floor, you will tell them there is 1 apartment available for that floor.
Accomplish this in a method choice() which will return the number of apartments available on a given floor
After you output how many apartments are available, ask the user if they wish to rent an apartment on that floor.
If the user states Yes, then move on to Third Goal; If the user responds No, then prompt them for another floor. This program assumes the user will rent an apartment on at least one of the floors they can afford. You can also either user the strings Yes and No or some other Boolean means to signal they have made their choice.
Third Goal:
Thank the user for their choice, confirm their choice by outputting the apartment floor and price they have chosen, then decrement the number of apartments available in Apts[] for that floor.
Output the Apts [] array and the Rents[] array.
You MUST use the following data to get credit:
You can hardcode and initialize the following values for your arrays:
Apts[] ={5, 3,1,2} and Rents[] ={200, 350, 450, 600}
Test your code using the following data (shown with prompt text which you can customize) which should be shown in the screenshot:
Welcome to KSU Rents!
Please enter the amount of money you have to spend on an apartment:
550
You can rent an apartment on floors 2 and below.
Which floor would you like to inquire about?
2
Floor 2 has 1 apartment available
Would you like an apartment on floor 2 (Enter Yes or No)?
No
Which floor would you like to inquire about?
1
Floor 1 has 3 apartments available
Would you like an apartment on floor 1(Enter Yes or No)?
Yes
Thank you for renting with us! You have an apartment on floor 1 for 350 dollars
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
