Hello!
I'm doing a thing to where the java program will let the user input a length, and width of a triangle. In return it will show the length, width, and the area. I think I have everything correct here, however, the public voids I inserted does not work... Any help on fixing this?
Thanks
import javax.swing.JOptionPane;
import java.util.Scanner;
public class AreaRectangle
{
public static void main(String[] args)
{
double length; // The rectangle's length
double width; // The rectangle's width
double area; // The rectangle's area
String input;
String output;
String STR1 = "Please enter the length: ";
String STR2 = "Please enter the width: ";
String STR3 = "Your area of the triangle is: ";
// Get the rectangle's length from the user.
public void getLength(double length)
{
Scanner keyboard = new Scanner(System.in);//enables keyboard
System.out.println(STR1);//outputs STR1
length = keyboard.nextDouble();//input gets saved as value
length = getLength();
}
// Get the rectangle's width from the user.
public void getWidth(double width)
{
Scanner keyboard = new Scanner(System.in);//enables keyboard
System.out.println(STR2);//outputs STR2
width = keyboard.nextDouble();//input gets saved as value
width = getWidth();
}
// Get the rectangle's area.
public void getArea(double area)
{
area = getArea(length, width);
{
// Display the rectangle data.
System.out.println(length, width, area);
}
}