Computer Science, asked by ruchi396, 1 year ago

write a Java Program that inputs the number of sides of a polygon and then determines whether it is an hexagon or a pentagon or a rectangle or a triangle

Answers

Answered by Incredible29
8
Heya user
Here is your answer !!

____________

import java.util.*;
public class Polygon
{
public static void main ( String args [] )
{
Scanner in = new Scanner ( System.in ) ;
System.out.print ( " Enter the no. of sides : " ) ;
int s = in.nextInt() ;
if ( s == 3 )
System.out.println ( " It is a Triangle " );
else if ( s == 4 )
System.out.println ( " It is a Rectangle " ) ;
else if ( s == 5 )
System.out.println ( " It is a Pentagon " ) ;
else if ( s == 6 )
System.out.println ( " It is a Hexagon " ) ;
else
System.out.println ( " Wrong choice " ) ;
}
}

____________


Hope it helps !!

Incredible29: plz follow if u lyk my answer
ruchi396: Okk,,,I'll follow and thanks for ur answer
Incredible29: u r welcm
Similar questions