OK, I'm having trouble with another program. This program is for a multiplication table using nested loops. Here are the instructions:
Purpose: To learn how to convert integers to strings, how to format text, how to use nested loops.
Write a program that (algorithmically) shows a times table.
In other words, I want to type
java Times
and see
To do this, you will need to know how to:
use nested loops
convert integers to strings
format text
Here's the code I have so far:
And, here's the error message I get when I try to compile:
C:\Documents and Settings\Benjamin Q. Chau\WRITTENPROGRAMS>javac Times.java
Times.java:15: cannot resolve symbol
symbol : variable display
location: class Times
display += i;
^
Times.java:20: cannot resolve symbol
symbol : variable display
location: class Times
display += " " + i *
^
Times.java:22: cannot resolve symbol
symbol : variable display
location: class Times
display += " " + i * j
^
Times.java:26: cannot resolve symbol
symbol : variable display
location: class Times
display += "\n";
^
Times.java:27: cannot resolve symbol
symbol : variable display
location: class Times
System.out.println(display);
^
5 errors
Now, I'm thinking the display variable can be used as such when I declare it as a
string and set it equal to "" (which I understand to mean null). I write "display +=" because I'm thinking this involves a concatenation operation and you can do this with strings? But when you do it with integers it becomes an arithmetic operation? I'm still a little fuzzy about that. I believe the errors point to the display variable as being the main culprit why the program is not compiling.
Also, I'm still having trouble determining when I use the capital letter as in "String" to declare a variable as opposed to when to use the lowercase letter such as in "string". I know that the capital references the class, in this case, the String class, but when specifically, are each used?
Thanks all. Any help would be greatly appreciated...
Benjamin
[ November 19, 2008: Message edited by: Benjamin Chau ]