Simple program, simple problem
Hey guys, I have to write a program using methods that will calculate the area of a rectangle. I'm using textpad and when I try to compile it says:
<identifier> expected on line 84
(which is the last header: public static void displayData(double length, double width, area);)
I tried adding:
area= Double.parseDouble(input);
a line before "return length * width, and a "double" before area in the header, but that just gave me even more errors! Any suggestions? Here is my program:
import javax.swing.JOptionPane;
public class AreaRectangle
{
public static void main(String[] args)
{
double length, // The rectangle's length
width, // The rectangle's width
area; // The rectangle's area
// Get the rectangle's length from the user.
length = getLength();
// Get the rectangle's width from the user.
width = getWidth();
// Get the rectangle's area.
area = getArea(length, width);
// Display the rectangle data.
displayData(length, width, area);
System.exit(0);
}
/**
Get the rectangle's length
@return The length
*/
public static double getLength()
{
String input;
double length;
input = JOptionPane.showInputDialog("Please enter the rectangle's length.");
length = Double.parseDouble(input);
return length;
}
/**
Get the rectangle's width
@return The width
*/
public static double getWidth()
{
String input;
double getWidth;
input = JOptionPane.showInputDialog("Please enter the rectangle's width.");
width = Double.parseDouble(input);
return width;
}
/**
Find the area of the rectangle
@return The area
*/
public static double getArea (double length, double width)
{
return length * width;
}
/**
Display the rectangle data
@param length The rectangle's length
@param width The rectangle's width
@param area The rectangle's area
*/
public static void displayData(double length, double width, area);
{
JOptionPane.showmessageDialog(null, length + "x" + width + "=" + "a rectangle area of" + area);
}
}