View Single Post
Old
chickentree
Super Moderator
 
Status: Offline
Posts: 250
Join Date: Dec 2012
Location: Frosno, Ca
Default 11-18-2015, 03:26 PM

Quote:
Originally Posted by LebronJames View Post
I even woke up before class to speak with my professor during his office hours which he was busy with registering students for next semester so I completed what I could but became very lost from there. I will Highlight what I have completed so far in my Alice world. The info that is Bold are the Questions I need help with but I attached my world work I have so far for you to inspect.

1) Place a chicken in the world. Create a method named chickenSquare that takes a parameter named size to indicate the size of the square. Using a loop, have the chicken move in a square where all movement is ‘forward’ (so the chicken will need to turn). Next create a method named chickenManySquares that takes a numeric parameters count and size. It then uses chickenSquare to make the chicken move in count number of squares of the given size. If the count isn’t valid (because it is negative) then the method should do nothing.

2) Write a method named findRem5. It asks the user for two numbers start and end. End must be > start and if it isn’t, the program should continue asking the user for a value until end is > start. It then counts up starting from start to end by ones printing each value. In addition to printing the number, if that number is divisible by 5 it should print an * beside it. For example, if start was 3 and end was 12 the output would be:
3.0
4.0
5.0*
6.0
7.0
8.0
9.0
10.0*
11.0
12.0
Lets Start with findRem5.
The big problem here is the while loop you included in the for loop. It says while True do nothing. The result is as follows:
  1. The first number is printed.
  2. The while statement evaluates True to determine if it is true. Question when will True be False??
  3. Since True is True perform the instructions within the while loop. In this case nothing is done.
  4. Evaluate the while condition and if true return to step 3, otherwise continue with the next instruction after the while loop.
The upshot is that the program is stuck in a while loop that can never end.

Other things to look at are the condition used to accept the end value. Your problem description says that end must be greater than start. Can you see why the use of end < start could be a problem?

You have not done the asterisk for values divisible by 5. The easiest way to check for this, since Alice does not have a Mod function, is to compare X/5 to Int(X/5). If they are equal then X is divisible by 5.

Mark


Mark Henwood
mhenwood@ieee.org
   
Reply With Quote