Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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.

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.

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.

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 can gain 2 extra points on this final lab by creating a third array containing the floor numbers: floor[] = {0,1,2,3} and sorting all the arrays based on availability so your apts[] array will be your guiding array and will be sorted from lowest to highest. The other arrays (floor[] and rents[]) will have to be kept in sync. Output the sorted arrays.

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

More Books

Students also viewed these Databases questions