Write a Java program such that it consists of 2 classes: 1. a class that serves as the driver (contains main()) 2. a class that contains multiple private methods that compute and display a. area of a triangle (need base and height) b area of a circle (use named constant for PI) (need radius) c. area of rectangle (width and length) d. area of a square (side) e. surface area of a solid cylinder (height and radius of base) N.B. You will also need an accessor public method (interface) that is called from the driver. This method should: a. Display a menu of options to the user. (Suggest use switch statement) b. Accept input from the user (keyboard) representing parameter values needed.
Write a Java program such that it consists of 2 classes: 1. a class that serves as the driver (contains main()) 2. a class that contains multiple private methods that compute and display a. area of a triangle (need base and height) b area of a circle (use named constant for PI) (need radius) c. area of rectangle (width and length) d. area of a square (side) e. surface area of a solid cylinder (height and radius of base) N.B. You will also need an accessor public method (interface) that is called from the driver. This method should: a. Display a menu of options to the user. (Suggest use switch statement) b. Accept input from the user (keyboard) representing parameter values needed.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question

Transcribed Image Text:### Java Programming Exercise: Creating a Class for Area Calculations
This exercise involves writing a Java program consisting of two classes:
1. **Driver Class**:
- Contains the `main()` method.
2. **Computation Class**:
- Includes private methods to compute and display:
1. **Area of a Triangle**: Requires base and height.
2. **Area of a Circle**: Use a named constant for PI; requires radius.
3. **Area of a Rectangle**: Requires width and length.
4. **Area of a Square**: Requires side length.
5. **Surface Area of a Solid Cylinder**: Requires height and radius of the base.
#### Implementation Details
- **Public Method (Interface)**:
- Called from the driver class.
- Should:
a. Display a menu of options to the user (suggest using a switch statement).
b. Accept input from the user representing parameter values needed.
c. Invoke private methods in the class to perform the necessary area computations.
- **Additional Instructions**:
- Add comments throughout your code as appropriate for clarity.
This program will help in understanding the concepts of classes, methods, and user interaction in Java.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps

Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education