Note: Please keep the programs that you create today, in case you have a dispute about your grades for the ICEs at the end of the quarter. When you're working with a partner, each person should save their own, individual copy
Download the ICE_15_For_1.java file, and change all of the counting while loops to be for loops, instead. Make sure that the program still compiles, and continues to do the same thing it did before your modifications.
Here is a quick picture to remind you how the two loops (while loops and for loops) are equivalent):
int i = 0;
// same as
for(int i = 0;
i < 4 ;
// no i++ here!
Locate a Java file that contains a robot within it. This can be something you download from the website right now, or any file that you’ve previously downloaded.
Use a for loop to have the robot move forwards 6 spaces.
Once you’ve gotten that to compile and run,
compare and contrast the while loop with the for loop. In particular, be
prepared to explain what sort of situation(s) a for loop is really good
for, and what sort of situation(s) a while loop is really good for.
Hint: When someone (usually a teacher J ) tells you to ‘compare and contrast’, you should basically end up with two lists: how the two things are similar (this is the comparison), and how the two things are different (this is the contrast).
Goal: Be able to write a nested for loop from scratch, that doesn't use Robots
Download the file ICE_15_For_4.java. You'll notice that it's pretty much a bare-bones .Java file. Your job is to create code in main that will print out a row of asterisks, like so:
You can pick how long you want that line to be. The important part is that I want you to be able to modify only one single line of code, and by modifying that single line, have the code print out as many asterisks as you want.
Remember that if you want to print some text, without moving to the next line, you use
System.out.print("*"); // note that it's print, not printLN