Draw a continuous wave | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Draw a continuous wave

What can I do to make the wave go vertical, rather than horizontal, based on how many times the user wants it go based on his input? import java.util.Scanner; public class Wave { public static void main(String[] args) { System.out.println("Enter how long you want your wave to go: "); Scanner s = new Scanner(System.in); int x = s.nextInt(); for (int i = 0; i < x; i++) { System.out.print("* *"); System.out.print(" * * "); System.out.print(" * * "); System.out.print(" ** "); } } }

13th Mar 2021, 12:28 PM
Barbarian
5 Answers
+ 4
This is solution extending your idea and and works up to screen width: https://code.sololearn.com/c3UeAaN9rgTR/?ref=app
13th Mar 2021, 1:33 PM
JaScript
JaScript - avatar
0
Use System.out.println as method "println" prints each string in a new line while "print" prints in same line
13th Mar 2021, 12:46 PM
Abhay
Abhay - avatar
0
then i just get a line of * *** ** * ** *** **************. i need to loop the V many times, horizontally (sorry, i wrote vertically, my bad)
13th Mar 2021, 12:56 PM
Barbarian
0
Barbarian if i input 2,then how exactly the pattern should look like ?
13th Mar 2021, 1:07 PM
Abhay
Abhay - avatar
0
* ** * * * * * * * * * ** ** and so on
13th Mar 2021, 1:16 PM
Barbarian