Hi
I am trying to create a program that finds the area of a triangle. I can easily find the area of the triangle but the problem is that I have been said to use the set and get method to calculate the area. I have no idea of how to use get and set method with an object. Any help or advice. I have posted my code below.
Code:public class TriObj { public void runIt() { Scanner in = new Scanner (System.in); int b; int h; int a; System.out.println("Enter b of triange: "); b=in.nextInt(); System.out.println("Enter h of triange: "); h=in.nextInt(); a=(b*h/2); System.out.println("The a of the triangle is: "+ a); } }
Bookmarks