Computer Science, asked by Acakefromdafuture32, 6 months ago

Write a program to input the sides of a polygon and tell whether it is a hexagon, pentagon or a triangle

Pls help me​

Answers

Answered by ranjitkumarkumar
1

Answer:

Triangle = 3

Hexagon=6

Pentagon =5

Answered by Anonymous
2

import java.util.Scanner;

public class polygon

{    

public static void main(String args[])    

{        

int poly_side;        

System.out.print("No. of sides : ");        

Scanner input=new Scanner(System.in);        

poly_side=input.nextInt();                

switch(poly_side)        

{            case 3:                

                       System.out.println("It is a Triangle");                

                       break;

            case 4:

                      System.out.println("It is a Rectangle");

                      break;

            case 5:                

                       System.out.println("It is a Pentagon");

                       break;

            case 6:

                       System.out.println("It is a Hexagon");

                       break;

           default:

                       System.out.println("Invalid Shape");                        

}    

}

Similar questions