Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Learning To Program with Robots: Java The link for the textbook: http://www.lear

ID: 3866815 • Letter: L

Question

Learning To Program with Robots: Java

The link for the textbook: http://www.learningwithrobots.com/textbook/PDFs/WholeThing.pdf

The Account class models a bank account. Identify which type of variable (temporary, parameter, or instance) should be used in each of the following val ues. Justify your answers using Table 6-4 a. The bank account's balance. 6.2 b. The amount to deposit in the account. c. The account's current interest rate. d. The amount of interest carned in the last month. Listing 6-12 and Listing 6-13 contain code for counterBot1 and CounterBot2, both of with things between the robot's current location and a wall. Consider executing the following main method in the initial situation shown in Figure 6-15 Execute it again, but using counterBot2 in line 3. The two solutions display diffcrent valucs for side1 and side2 6.3 which purport to count the number of intersections a. What arc the four valucs printed (two for CounterBotl and two for counterBot2)? b. Explain why they differ. 1 public static void main (stringt args) { city testc1ty = new city ("tcstCity.txt "); counterBot1 kare! = new counterBot1( . . . ) ; int side 1 = karel.numIntersectionswithThings(); int side2 = kare1.numIntersectionswithThings(); 6 karel.turnLeft 8 9 System.out.println("sidcl- sidel); 10 System.out.println("side2 -side2);

Explanation / Answer

6.1: a) The account balance has to be instance variable because it will remain as long as the object is in the memory.

b) Amount to deposit can be a parameter as we dont need this data later on because the amount gets added to account balance which is persistent.

c) Current interest rate has to be instance variable because it will remain throughout the lifetime of the object

d) Interest in last month again has to be persistent

The second part of your question is incomplete. The complete code is required with proper documentation. So far what I could understand with the given code is that the round black balls are the things between robot and wall. If so the after turning left the value is definitely gonna change.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote