Question: JAVA: UML Diagram. Create a Rectangle Class and a parallelpiped Class to go along with the given client: To produce given output: ################## UML Diagram

JAVA: UML Diagram.

Create a Rectangle Class and a parallelpiped Class to go along with the given client: To produce given output:

##################

UML Diagram

###################

JAVA: UML Diagram. Create a Rectangle Class and a parallelpiped Class to

#######################

Output:

##################

SAMPLE RUNS:

RUN #1:

Created rectangle r1 with width 1; height 2

Created parallelpiped p1 with width 1; height 2; length 3

Enter an integer for the width of rectangle r2 >

1

Enter an integer for the height of rectangle r2 >

2

Created rectangle r2 with width 1; height 2

Rectangle r2 is equal to r1

Rectangle r1 perimeter is 6

Rectangle r1 area is 2

Rectangle r2 perimeter is 6

Rectangle r2 area is 2

We will build a parallelepiped p2 from rectangle r2

Enter an integer for the length of parallelepiped p2 >

3

Created paralellepiped p2 with width = 1; height = 2; length = 3

Paralellepiped p2 is equal to p1

Paralellepiped p2 area is 22

Paralellepiped p2 volume is 6

RUN #2

Created rectangle r1 with width 1; height 2

Created parallelpiped p1 with width 1; height 2; length 3

Enter an integer for the width of rectangle r2 >

2

Enter an integer for the height of rectangle r2 >

1

Created rectangle r2 with width 2; height 1

Rectangle r2 is not equal to r1

Rectangle r1 perimeter is 6

Rectangle r1 area is 2

Rectangle r2 perimeter is 6

Rectangle r2 area is 2

We will build a parallelepiped p2 from rectangle r2

Enter an integer for the length of parallelepiped p2 >

3

Created paralellepiped p2 with width = 2; height = 1; length = 3

Paralelepiped p2 is not equal to p1

Paralellepiped p2 area is 22

Paralellepiped p2 volume is 6

RUN #3

Created rectangle r1 with width 1; height 2

Created parallelpiped p1 with width 1; height 2; length 3

Enter an integer for the width of rectangle r2 >

1

Enter an integer for the height of rectangle r2 >

2

Created rectangle r2 with width 1; height 2

Rectangle r2 is equal to r1

Rectangle r1 perimeter is 6

Rectangle r1 area is 2

Rectangle r2 perimeter is 6

Rectangle r2 area is 2

We will build a parallelepiped p2 from rectangle r2

Enter an integer for the length of parallelepiped p2 >

5

Created paralellepiped p2 with width = 1; height = 2; length = 5

Paralelepiped p2 is not equal to p1

Paralellepiped p2 area is 34

Paralellepiped p2 volume is 10

############################

Client:

###########################

/* ParallelepipedClient class Anderson, Franceschi */

import java.text.DecimalFormat; import java.util.Scanner;

public class ParallelepipedClient { public static void main( String [] arr ) { Scanner scan = new Scanner( System.in ); Rectangle r1 = new Rectangle( 1, 2 ); System.out.println("Created rectangle r1 with " + r1.toString()); Parallelepiped p1 = new Parallelepiped( 1, 2, 3 ); System.out.println("Created parallelpiped p1 with " + p1.toString());

System.out.println( " Enter an integer for the width of rectangle r2 > " ); int w = scan.nextInt( ); System.out.println( "Enter an integer for the height of rectangle r2 > " ); int h = scan.nextInt( );

Rectangle r2 = new Rectangle( w, h );

System.out.println( "Created rectangle r2 with " + r2 ); if ( r2.equals( r1 ) ) System.out.println( "Rectangle r2 is equal to r1"); else System.out.println( "Rectangle r2 is not equal to r1");

System.out.println( " Rectangle r1 perimeter is " + r1.perimeter( ) ); System.out.println( "Rectangle r1 area is " + r1.area( ) ); System.out.println( " Rectangle r2 perimeter is " + r2.perimeter( ) ); System.out.println( "Rectangle r2 area is " + r2.area( ) );

System.out.println( " We will build a parallelepiped p2 from rectangle r2" ); System.out.println( "Enter an integer for the length of parallelepiped p2 > " ); int l = scan.nextInt( );

Parallelepiped p2 = new Parallelepiped( w, h, l ); System.out.print("Created paralellepiped p2 with width = " + p2.getWidth()); System.out.print("; height = " + p2.getHeight()); System.out.println("; length = " + p2.getLength());

if ( p2.equals( p1 ) ) System.out.println( "Paralellepiped p2 is equal to p1" ); else System.out.println( "Paralelepiped p2 is not equal to p1" );

System.out.println( " Paralellepiped p2 area is " + p2.area( ) ); System.out.println( "Paralellepiped p2 volume is " + p2.volume( ) ); } }

Rectangle width int int e height mRectangle(int, int) int int void void String getWidth() m getHeight0 msetWidth (int) msetHeight(int) toString() mequals(Object) boolear mperimeter() m area0) int int Parallelepiped int a length m Parallelepiped(int, int, int) m getLength(0) m setLength(int) mtoString) m equals(Object) m area mvolume) int voidcreate String boolean int int create ParallelepipedClient mmain (String[I) void

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!