Results 1 to 3 of 3
- 11-11-2010, 09:28 PM #1
Member
- Join Date
- Nov 2010
- Posts
- 7
- Rep Power
- 0
Can someone look over this java program please?
Its suppose to output a triangle depending on the users input
ex
input-3
output
3
33
333
33
3
input-7
output
7
77
777
7777
77777
777777
7777777
777777
77777
7777
777
77
7
I know that right now it won't really work for numbers over 9
here it is
import java.util.Scanner;
public class TriangleOfDigits
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
int rows = input.nextInt();
//outer loop says how many lines
//*n by 2 and - 1 (how many lines needed
for (int rowNumber = 1; rowNumber <= rows; rowNumber++);
{
//inner loop says how many things on this line
for(int colNum = 1; colNum <= rowNumber; colNum++);
{
//print out thing
System.out.print(rows);
}
System.out.println();
}
for (int rowNumber = 1; rowNumber <= rows; rowNumber++);
{
//inner loop says how many things on this line
for(int colNum = rows; colNum > rowNumber; colNum--);
{
//print out thing
System.out.print(rows);
}
}
System.out.println();
}
}
These are the error messages Im getting
TriangleOfDigits.java:16: cannot find symbol
symbol : variable rowNumber
location: class TriangleOfDigits
for(int colNum = 1; colNum <= rowNumber; colNum++);
^
TriangleOfDigits.java:31: cannot find symbol
symbol : variable rowNumber
location: class TriangleOfDigits
for(int colNum = rows; colNum > rowNumber; colNum--);
Im not quite sure how to fix this
thanks in advance
- 11-11-2010, 09:35 PM #2
Senior Member
- Join Date
- Feb 2009
- Posts
- 303
- Rep Power
- 5
You're for loops shouldn't have the ';' after the declaration. It should look like this.
Take the ';' off the for loops and see what you get.Java Code:for (int i = 0; i < list.size(); i ++) { //your code here... }
- 11-11-2010, 10:09 PM #3
Member
- Join Date
- Nov 2010
- Posts
- 7
- Rep Power
- 0
Similar Threads
-
how to call 2 java programs in one another java program
By renu in forum New To JavaReplies: 8Last Post: 09-30-2010, 06:32 PM -
Is There A Way To Call Another Java Program Within A Java Program
By SwissR in forum New To JavaReplies: 4Last Post: 07-30-2010, 12:25 PM -
execute java program within java program
By popey in forum New To JavaReplies: 2Last Post: 10-22-2009, 05:32 PM -
How to execute an External Program through Java program
By Java Tip in forum java.ioReplies: 0Last Post: 04-04-2008, 02:40 PM -
How to execute an External Program through Java program
By JavaBean in forum Java TipReplies: 0Last Post: 10-04-2007, 09:33 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks