Computer Science, asked by anshumankanungp7xjpz, 1 year ago

write a program that inputs number of sides of a polygon and then determines whether it is a hexagon , a pentagon, a rectangle or a triangle
java

Answers

Answered by frederickgomespakvin
24
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");                       
}   
}
Answered by serena123
0

Answer:

can someone rewrite this in c++

I'm sure I'll mark who answers correct as brainlest

Similar questions