ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 12 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 27 Apr 2017 My Price 8.00

Write a Java program, called MethodOverload

MethodOverload:

Write a Java program, called MethodOverload that contains 5 static methods called area(). Each of these methods will calculate the area of a user inputted shape; they will take in different parameters as below. They should all return a double and calculate the area of the corresponding shape (formulas given):

  • ï‚· area(<int>) -> Area of a square = len^2. len is the length of a side.
  • ï‚· area(<int>, <int>) -> Area of a Rectangle = w*h. w is the width of a side and h is the height.
  • ï‚· area(<double>, <int>) -> Area of an Triangle = (1/2)*b*h. b is the base and h is the height.
  • ï‚· area(<double>) -> Area of a Circle = pi*r^2. r is the radius of the circle.
  • ï‚· area(<double>, <double>) -> Area of an Ellipse = pi*a*b. a is (1/2) the length of the major axis and b is (1/2) the length of the minor axis. The major and minor axis will be given in the question.

The main method should take in user input to determine what shape the area needs to be calculated for. Depending on the shape given the program should then take in the correct parameters from the user (see Example below). Each input will be given in the order given in the descriptions above. You should also have an output if a non valid shape was entered. use "Not a valid shape!" as this message

(NOTE: you can use Math.PI to get the value of pi in Java)

Example:

- "Square 4" would determine that you are required to find the area of a square with a side length of 4.

- "Rectangle 4 4" would determine that you are required to find the area of a rectangle with width and height 4.

Input:

n x

where n is a string representing the shape, x is the number to go with the shape

Sample input :

Square 4

Output:

The area of a square with side of length 4

Sample output:

Area: 16.0

Answers

(11)
Status NEW Posted 27 Apr 2017 04:04 AM My Price 8.00

-----------

Not Rated(0)