Computer Science, asked by rockonhuntersingh, 1 year ago

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 Saloni001
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
Saloni001: welcm
rockonhuntersingh: i need more help..Would u prefer to help??
Saloni001: okk say
rockonhuntersingh: Seema and Viksh are looking to buy a house in a newly developed colony.After looking at various models, the three models which they like are colonial,spilt-entry, and a single-storey.the builder gave them the base price and the finished area in squre feet of the three models.They want to know model(s) with the least price per square foot.WAP that accepts as the input the base price and the finished area in squre feet of the three models.
rockonhuntersingh: The program should compute and display the output of the model(s) with the least price per square foot.
rockonhuntersingh: ???
Similar questions