1 i=0
2 i=i+1
3 PRINT i; "squared=";i*i
4 IF i>=100 THEN GOTO 6
5 GOTO 2
6 PRINT "Program Completed."
7 END
Credit: Wikipedia
Image Credit: XKCD
Programs only consist of:
1 FOR i=1 TO 100
2 PRINT i;"squared=";i*i
3 NEXT i
4 PRINT "Program Completed."
5 END
Credit: Wikipedia
Organize programs to represent real or theoretical "objects" that use:
class Squares{
public void printSquares(int limit){
for(int i = 0; i < limit; i++){
System.out.println("squared=" + (i*i));
}
System.out.println("Program Completed.");
}
}
We will use only object-oriented, structured code in this class.
It will help us write programs that are easier for others to understand.