Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Input The first input will be radius then followed by length and width at next line. Output CircleRectanglecalArea() Examples 5 input 46 output 78.50

image text in transcribedimage text in transcribed

Input The first input will be radius then followed by length and width at next line. Output CircleRectanglecalArea() Examples 5 input 46 output 78.50 24.00 Please declare a abstract class Shape, having the abstract method calArea() to compute the area of the shape. Two classes Rectangle and Circle are derived from Shape. Class Rectangle has float data field length and width. Class Circle has float data field radius. The main class is given as shown in Preset code. (Preset code) import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner in = new Scanner(System.in); double radius, length, width; radius = in.nextDouble(); Shape circle = new Circle(radius); System.out.println(String.format("%.2f",circle.calArea())); length = in.nextDouble(); width = in.nextDouble(); Shape rectangle = new Rectangle(length, width); System.out.println(String.format("%.2f", rectangle.calArea())); } } abstract class Shape{ public abstract double calArea(); }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

App Inventor

Authors: David Wolber, Hal Abelson

1st Edition

1449397484, 9781449397487

More Books

Students also viewed these Programming questions

Question

Solve. 2x - 5x + 2 = 0

Answered: 1 week ago