write a program that inputs no of sides of a polygon and then determine whether it is a hexagon,pentagon, a rectangle,or a triangle.
Answers
Answered by
2
write a program that inputs no of sides of a polygon and then determine whether it is a hexagon,pentagon, a rectangle,or a triangle.↓↓
your answer to this-------------------------------↓↓
→
import.java.util.*;
class polygon
{
public static void main()
{
int n;
Scanner sc=new Scanner (System.in);
System.out.println("enter no. of sides of polygons");
n=sc.nextInt();
if (n==6)
System.out.println("its a hexagon");
else
if (n==5)
System.out.println("its a pentagon");
else
if(n==4)
System.out.println("its a rectangle");
else
if(n==3)
System.out.println("its a triangle");
else
System.out.println("its not a hexagon,pentagon, a rectangle,or a triangle"):
}
}
Thankyou!!!!!!!!!!!!!!↑↑↑
rockonhuntersingh:
thanks a lot
Similar questions