contain viruses. Unless you need to edit, it's safer to: e cted View. Enable Editing Assignment 4 Part (1) Create a class called Triangle that has two private instance variables: base and height...

Java 1contain viruses. Unless you need to edit, it's safer to: e cted View.<br>Enable Editing<br>Assignment 4<br>Part (1)<br>Create a class called Triangle that has two private instance variables: base and height (double)<br>Additionally, the class should have:<br>(a) A constructor that takes base, and height. The constructor sets the class variables to<br>these values and in case any of these values is negative, set its instance variable to zero.<br>(b) A mutator methods (set) and an accessor methods (get) for the base and height.<br>(c) A method getArea that returns the area of the Triangle. The area is computed by the<br>following formula:<br>base xheight<br>Area=<br>2<br>Part (2)<br>Write a Java application that asks the user to enter the base and height. Create an object from<br>Triangle class you did in Part (1) and use it to display the area.<br>Sample Run<br>C:\WINDOWS\system32\cmd.exe<br>Enter base and height of triangle:6 5<br>Area of triangle=15.0<br>Press any key to continue<br>. - -<br>TOSHIBA<br>

Extracted text: contain viruses. Unless you need to edit, it's safer to: e cted View. Enable Editing Assignment 4 Part (1) Create a class called Triangle that has two private instance variables: base and height (double) Additionally, the class should have: (a) A constructor that takes base, and height. The constructor sets the class variables to these values and in case any of these values is negative, set its instance variable to zero. (b) A mutator methods (set) and an accessor methods (get) for the base and height. (c) A method getArea that returns the area of the Triangle. The area is computed by the following formula: base xheight Area= 2 Part (2) Write a Java application that asks the user to enter the base and height. Create an object from Triangle class you did in Part (1) and use it to display the area. Sample Run C:\WINDOWS\system32\cmd.exe Enter base and height of triangle:6 5 Area of triangle=15.0 Press any key to continue . - - TOSHIBA

Jun 02, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here