Computer Science, asked by pramukh0504, 1 year ago

write a java program to find area of Pentagon, accept values through parameter

Answers

Answered by rockingriti0406
1

I was trying to write a code to take the radius of a pentagon and turn it into a side, then output the area. Somewhere along the way my use of the math class is incorrect. (New to this site but tried to format everything so you could understand my program)

Class:   CS 1301/16

// Term: Fall

// Name: Gabriel Tomasetto

// Intsructor: Ms. Tulin  

// Assignment 1

import java.util.*;

public class Pentagon {

 public static void main(String[] args) {

 Scanner scan = new Scanner(System.in);

 double radius, side, area;

 System.out.println("Please enter the length of the Pentagon from the center to the vertex: ");

 radius = scan.nextDouble();

 side = (2 * radius) * (Math.sin(Math.PI/5)); //I'm assuming I'm not correctly using the Math class to represent the equation? Thoughts.

 area = (5 * Math.pow(radius, 2)) / (4 * Math.tan(Math.PI /5));

 System.out.println("The area of the Pentagon is:\t" + area);

                                     }

                  }


pramukh0504: parameter means bluej way
Similar questions