array troubles

My assignment for this week is create a program, which uses arrays, that accepts a series of numbers and then prints each number followed by a string of * characters equal to the number.

Here is a sample of the program:

> Enter the length of the series: 5

> Enter number 1: 4

> Enter number 2: 2

> Enter number 3: 7

> Enter number 4: 1

> Enter number 5: 9

>

> 4 ****

> 2 **

> 7 *******

> 1 *

> 9 *********

Here is what i have so far...

import java.util.*;

publicclass TextGraph{

publicstaticvoid main(String[] args){

Scanner keyboard =new Scanner(System.in);

System.out.print("Enter the length of the series: ");

int series = keyboard.nextInt();

int[] input =newint[series];

for (int i = 0; i < series; i++){

System.out.print("Enter number: ");

input[i] = keyboard.nextInt();

}

for (int i = 0; i < input[i]; i++){

System.out.println(input[i] +"* ");

}

}

}

I just cant seem to figure out how to print the '*' equal to the value inputed. Can someone give me any tips or lead me in the right direction to solving this?

[2002 byte] By [rudskya] at [2007-11-27 11:18:47]
# 1

You'll need a nested loop, the outer loop loops over the array, the inner loop loops as many times as the number in the array at the current index according to the outer loop.

dwga at 2007-7-29 14:33:02 > top of Java-index,Java Essentials,New To Java...
# 2

Your code would be like the next:

for(loop over the length of the series){

take a new number from the user:

for(loop over the number entered){

print("*");

}

System.out.println();

}

hope it helps (^_^);

QussayNajjara at 2007-7-29 14:33:02 > top of Java-index,Java Essentials,New To Java...