Here We Continue With Variable Use Clara Is Learning To Optimise Her Movement And Fo 2767079

Here we continue with variable use. Clara is learning to optimise her movement and for this to happen she must learn to count. One of the tasks set out for her is to compute the height of the longest line of trees.

Clara starts in the world as shown in Figure 1. She must move from west to east and once reaching a leaf at the bottom right corner – she must present the value of the longest tree line she has encountered in the world. The outcome should resemble what is shown in Figure 2.

Figure 1Figure 1.Figure 2Figure 2.

This problem has many similarities with the Steeple Chase example covered in Lecture 3. But one of the main differences is that the world is not surrounded by trees and we do not know how many tree lines will there be present in Clara’s world. But you can always count on the fact that a leaf is located in the bottom right corner to help you decide when to stop counting. Your solution must be generic and work with all supplied example worlds.

Important !!!

To print the variable use following command (assuming that your variable name is maxStep):

System.out.println(‘The longest line is ‘ + maxStep + ‘ trees long’);

If you use different text message you will see incorrectOutput error:

Figure 3Figure 3.

 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
Looking for a Similar Assignment? Our Experts can help. Use the coupon code SAVE30 to get your first order at 30% off!