0
How to print hexagon using scanner in java
Using java and scanner
1 Answer
+ 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]