Exercise 2: A. Write static methods: public static double cubeVolume(double h) : h public static double cubeSurface(double h) : 6h2 public static double cylinderVolume(double r, double h) : hnr? public static double cylinderSurface(double r, double h) : 2rnh + 2nr? that compute the volume and surface area of a cube with height h, and a cylinder with circular base with radius r and height h. Place them into a class named "Geometry.java". Then write a program with main class called "Lab7_yourlID.java" that prompts the user for the values of r and h, calls the four methods, and prints the results. B. (Optional) Reconsider your previous solution by implementing classes Cube, and Cylinder separately instead of a single class "Geometry" (part A). Which approach is more object-oriented?

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter10: Object-oriented Programming
Section: Chapter Questions
Problem 15RQ
icon
Related questions
Question

Java language 

Exercise 2:
A Write static methods:
public static double cube Volume(double h) : h
public static double cubeSurface(double h) : 6h2
public static double cylinderVolume(double r, double h) : hTr
public static double cylinderSurface(double r, double h) : 2rnh + 2r?
that compute the volume and surface area of a cube with height h, and a cylinder with
circular base with radius r and height h. Place them into a class named
"Geometry java". Then write a program with main class called "Lab7 yourlD java"
that prompts the user for the values of r and h, calls the four methods, and prints the
results.
B. (Optional) Reconsider your previous solution by implementing classes Cube, and
Cylinder separately instead of a single class "Geometry" (part A). Which approach is
more object-oriented?
Transcribed Image Text:Exercise 2: A Write static methods: public static double cube Volume(double h) : h public static double cubeSurface(double h) : 6h2 public static double cylinderVolume(double r, double h) : hTr public static double cylinderSurface(double r, double h) : 2rnh + 2r? that compute the volume and surface area of a cube with height h, and a cylinder with circular base with radius r and height h. Place them into a class named "Geometry java". Then write a program with main class called "Lab7 yourlD java" that prompts the user for the values of r and h, calls the four methods, and prints the results. B. (Optional) Reconsider your previous solution by implementing classes Cube, and Cylinder separately instead of a single class "Geometry" (part A). Which approach is more object-oriented?
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Introduction to computer system
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage