Question: Help me with Java. Main.java as tester so 2 java file is needed thanks sample program: MY ASSIGNMENT:: PS. We are using onlinegdb Main.java RightTriangle.java:

Help me with Java. Main.java as tester so 2 java file is needed thanks

sample program:

Help me with Java. Main.java as tester so 2 java file is

needed thanks sample program: MY ASSIGNMENT:: PS. We are using onlinegdb Main.java

MY ASSIGNMENT:: PS. We are using onlinegdb

RightTriangle.java: 2 3 Welcome to GDB Online. 4 GDB online is an

Main.java RightTriangle.java: 2 3 Welcome to GDB Online. 4 GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl, 5 C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog. 6 Code, compile, Run and Debug online from anywhere in world. 7 8 9 public class Main 10 - { 11 public static void main(String[] args) { 12 Right Triangle ti new RightTriangle(); 13 RightTriangle t2 = new RightTriangle(40, 50); 14 RightTriangle t3 = new RightTriangle(101); 15 RightTriangle t4 = new RightTriangle(10.56f); 16 17 t1.setBase(4); 18 ti.setHeight(5); 19 20 //t2.setBase(40); 21 //t2.setHeight(50); 22 23 //t3.setBase (400); 24 //t3.setHeight(500); 25 26 System.out.println("Triangle ti base = " + t1.getBase() + ", height = + t1.getHeight() + 27 28 System.out.println("Triangle t2 base t2.getBase() + ", height " + t2.getHeight() + 29 30 System.out.println("Triangle t3 base = + t3.getBase() + ", height + t3.getHeight() + 31 32 System.out.println("Triangle t4 base = + t4.getBase) ", height = + t4.getHeight() 33 } 34 } 35 ", area = + ti.area()); ", area + t2.area()); ", area t3.area()); ", area + t4.area()); Run 21 Fork this Main.java Right Triangle.java: 1. public class RightTriangle{ // properties / instance varuable / field private int base; private int height; //methods 7 //constructor 9 public Right Triangle(){ 10 base = e; 11 height = ; 12 } 13 14 public RightTriangle(int b, int h){ 15 base = b; 16 height = h; 17 } 18 19 public RightTriangle(int b){ 20 base = b; height = b; 22 } 23 24 public RightTriangle(float x){ base = (int)x; 26 height = (int)x; 27 } // getter methods 30 public int getBase(){ 31 return base; 32 } 33 34 public int getHeight(){ 35 return height; } 37 // setter methods 39 public void setBase(int b){ 40 base = b; 41 } 42 43 public void setHeight(int h) { 44 height = h; 45 } 46 public double area(){ 48 return (.5 * base * height); 49 } 50 51 36 38 47 Draft version - Back to Classroom Submit Before: 3/15/2021, 1:54:00 PM Run Debug Stop A Save Asubmit Lan Rectable Main.java 1- public class Rectangle{ 2 private int length; private int width; 4 5} 6 Create a class Rectangle that contains area) and perimeter() methods

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!