Question: write 2 java codes 1. user-defined 2. end user 1. Create a 'user-defined' class containing two methods. One for calculating the area of a triangle,
1. Create a 'user-defined' class containing two methods. One for calculating the area of a triangle, and the other one is for calculating the area of a circle. 2. Each method receives parameter(s) for calculating an area and returns a result. 3. Create another class for 'end user'. This class should perform the following: Prompt the user for a shape. Suppose we have two shapes, a triangle and a circle. Prompt the user for the shape's dimension. Create an object(instance) of the user-defined class. Calculate the area of the shape using a method in the user-defined class. You must use the object (instance) when calling a method. Print the shape name and its area. A Sample log of execution (1) A Sample log of execution (2) Define a shape 1)triangle, 2)circle): 1 Define a shape 1)triangle, 2)circle): 2 Triangle Base: 10,0 Circle radius: 10.0 Triangle Height: 5.0 Triangle area: 25.00
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
