Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given the class diagram and progDemo below Shape +area(): double +circumference(): double ---> implements implements Square -side: double Square(double) +area(): double +circumference(): double Circle -radius:

Given the class diagram and progDemo below

image text in transcribed

image text in transcribed

Shape +area(): double +circumference(): double ---> implements implements Square -side: double Square(double) +area(): double +circumference(): double Circle -radius: double -pic double +Circle(double) +areal): double +circumference(): double Extends Cylinder |-height: double +Cylinder(double double) +area(): double +circumference(): double File progDemo.java public class progDemo public static void main(String [] args) { Shape sh = new Circle (1): System.out.println("The circle's area: " + sh.area()); System.out.println("The circle's circumference: " + sh.circumference()); sh = new Cylinder (2,2): System.out.println("The cylinder's area: "+sh area()); System.out.println("The cylinder's circumference: " + sh.circumference()); sh = new Square (4); College of Computer Laboratory Manual Operating Systems (CS222) Page 3 System.out.println("The square's area: "+sh. area()); System.out.println("The square's circumference: " + sh.circumference()); Requirements: Add class Square implementing the Shape interface O Area = Side2 .circumference = 4 * side Add class Cylinder inheriting the Circle class O Area = 2xrh + 2 tr , circumference = 2tr Run the code in file prog Demo for testing. The Output of the Program: The circle's area: 3.14 The circle's circumference: 6.28 The cylinder's area: 50.24 The cylinder's circumference: 12.56 The square's area: 16.0 The square's circumference: 16.0

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

What do you think of the MBO program developed by Drucker?

Answered: 1 week ago