hree double data fields named base, height, and hypotenuse that specifies ngth of the three sides of the right-angled triangle. The default values for e: o Base: 3.0 o Height: 4.0 o Hypotenuse: 5.0 no-arg constructor that creates a default triangle. constructor that creates a triangle with a specified base, height, and hypot hree get and set methods for each of the private data fields. method named getArea() that returns the area of the triangle: o Area = ¹/2 (base * height) method named getPerimeter() that returns the perimeter of the triangle: o Perimeter = base + height + hypotenuse ake sure to follow this sequence of steps: raw the UML of the Triangle class. The data fields should be private, and onstructors and all other methods should be public.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Need help writing the program creating two different class. Provide with ss of ur code if possible and UML diagram.

Define a class of Triangles.
Design a class named Triangle. This class represents a right-angled triangle. The class
contains:
Three double data fields named base, height, and hypotenuse that specifies the
length of the three sides of the right-angled triangle. The default values for each
are:
o Base: 3.0
o Height: 4.0
o Hypotenuse: 5.0
➤ A no-arg constructor that creates a default triangle.
➤ A constructor that creates a triangle with a specified base, height, and hypotenuse.
➤ Three get and set methods for each of the private data fields.
➤ A method named getArea() that returns the area of the triangle:
o Area = ½ (base * height)
A method named getPerimeter() that returns the perimeter of the triangle:
o Perimeter = base + height + hypotenuse
Please make sure to follow this sequence of steps:
1. Draw the UML of the Triangle class. The data fields should be private, and
constructors and all other methods should be public.
2. Implement the Triangle class (named “Triangle") in Triangle.java.
3. Implement the TestTriangle class (named “TestTriangle") with the main method
in Test Triangle.java. It should do the following tasks:
Create a default triangle object.
Change the triangle to have a base of 5.0, a height of 12.0, and a hypotenuse
of 13.0
Print out the area of the triangle.
Print out the perimeter of the triangle.
Transcribed Image Text:Define a class of Triangles. Design a class named Triangle. This class represents a right-angled triangle. The class contains: Three double data fields named base, height, and hypotenuse that specifies the length of the three sides of the right-angled triangle. The default values for each are: o Base: 3.0 o Height: 4.0 o Hypotenuse: 5.0 ➤ A no-arg constructor that creates a default triangle. ➤ A constructor that creates a triangle with a specified base, height, and hypotenuse. ➤ Three get and set methods for each of the private data fields. ➤ A method named getArea() that returns the area of the triangle: o Area = ½ (base * height) A method named getPerimeter() that returns the perimeter of the triangle: o Perimeter = base + height + hypotenuse Please make sure to follow this sequence of steps: 1. Draw the UML of the Triangle class. The data fields should be private, and constructors and all other methods should be public. 2. Implement the Triangle class (named “Triangle") in Triangle.java. 3. Implement the TestTriangle class (named “TestTriangle") with the main method in Test Triangle.java. It should do the following tasks: Create a default triangle object. Change the triangle to have a base of 5.0, a height of 12.0, and a hypotenuse of 13.0 Print out the area of the triangle. Print out the perimeter of the triangle.
The base before is
The height before is
The hypotenuse before is
The base after is
The height after is
The hypotenuse after is
The area is
The perimeter is
Transcribed Image Text:The base before is The height before is The hypotenuse before is The base after is The height after is The hypotenuse after is The area is The perimeter is
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY