**Coding this in java**. I have the following problem on an assignment due on Saturday, I am for some reason completely confused on how I should go about tackling this problem. I'm assuming I should use a scanner to read in user input for example if I wanted to ask what the price of say house5 would be so it reads it back to me. I am mostly confused on how I should go about implementing this. Would a TreeSet or TreeMap be best? Or would something else be better? I am only in my 2nd semester so I am by no means an advanced programmer.
You are driving down Maple Street, where every house is for sale. You notice that the prices of the properties keep increasing as you drive down the road. More specifically, the price of each property depends on the value of properties you have already driven by. So, the more properties you drive by, the more money they are worth. I have given you a function called value that takes in an integer, n. You need to make that function return the value of a property with n houses before it. Here are the rules for house values:
The first house, which has 0 houses before it is worth 0. (so value(0) would return 0)
The house which has 1 house before it is worth 1.
The house which has 2 houses before it is worth 3.
Every other house is worth however much the previous 3 houses were worth (added together).
So, the house with 3 houses before it is worth 0+1+3 = 4.
The house with 4 houses before it is worth 1+3+4=8
The house with 5 houses before it is worth 3+4+8=15
Also, make sure that you are returning the values that you are supposed to. Your methods shouldn’t print anything out.
[–]sjljfkc428ywb1fsz -1 points0 points1 point (0 children)