0
How to print hexagon using scanner in java
Using java and scanner
1 Respuesta
+ 13
□ For taking user input as integer :
● import java.util.Scanner; //importing Scanner class
● Scanner sc = new Scanner(System.in); //sc is object of Scanner class
● int n = sc.nextInt(); //.nextInt() to take ineteger input.
□ By hexagon, I am assuming U mean a regular hexagon.
● A hexagon can be made using 2 isosceles triangles & a square. [U should give it a try] :
● an isosceles triangle at top [with unequal side as base]
●below it an square with side as length of "unequal side of isosceles triangle"
● below it same isosceles triangle [upside down]