Question: The program you will create is to allow a user to enter the type of an apartment they would like (basement, 1st floor, 2nd floor,

The 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.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!