# problem with repeating characters

• 03-19-2011, 09:37 PM
ihitimdogg
problem with repeating characters
Code:

```package timsittlerbounceingball; import java.util.Scanner; public class Main {     public static void main(String[] args)     {         Scanner keyboard= new Scanner(System.in);         double vel, newvel, bounce, time, height;         bounce=0;         time=1;         System.out.println("Enter the inital velocity of the ball");         vel=keyboard.nextDouble();         height=vel;         System.out.println("Time:0 Height:0");         System.out.println("Time:1 Height:"+ vel);         while(bounce<6)         {             vel=vel-32; // code for velocity equation and resulting height             newvel=vel;             height=height+newvel;                       time++;         if (height<0) //simulates the bounce         {             height=height*-.5;             vel=vel*-.5;             System.out.println("Time:"+time+" Height:"+height);             bounce++;         }             else // during time in the air             System.out.println("Time:"+time+" Height:"+height);         }     } }```

this is a simple loop for a bounceing ball. What i need to do is to get a certain number of "*" to appear next to my height number. The number of "*" is dependent to height that is generated. For the life of me i can not figure this out. in other words i need a way to multiply "*" by the height. Any help would be great. Just need to be pointed in the right direction. Thanks
(p.s. very very new to the whole progamimg thing)
• 03-19-2011, 10:55 PM
Fubarable
Welcome to the forum. I suggest that you calculate your number, then use a loop to write out the "*" character based on this number. Since you'll know before the loop how many times you'll want the loop to occur, a for loop would work best. Since you want to print the "*" without carriage returns, you'll want to use System.out.print(...) inside the loop, and System.out.println() just after the for loop.

```[cod&#101;]   // your code goes here   // notice how the top and bottom tags are different [/cod&#101;]```