Hey everyone. I am new to java and I am stuck in this program. I am getting error messages and cannot figure out why. On public class Rectangle I am getting error messages on lines 84, and 85. On RectangleTest line 12. Thank you all in advance for and guidance or light you can shed on my issues!
//
public class Rectangle
{
int lenght; // lenght of rectangle
int width; // width of rectangle
// two arg constructor
public Rectangle( int l, int w )
{
lenght = l;// initialize length
width = w;// initialize width
}// end constructor
//method to set Lenght
public void setLenght( int l )
{
lenght = l;
}
//Method to retrieve Lenght
public int getLenght()
{
return lenght;
}
//method to set Width
public void setWidth( int w )
{
width = w;
}
//Method to retrieve Width
public int getWidth()
{
return width;
}
public void validate( int l, int w)
{
lenght = ( ( l >= 0 && l < 20) ? l : 1);// validate lenght
width = ( ( w >= 0 && w < 20) ? w : 1);// validate lenght
}
// finds the perimeter
public double perimeter( int l, int w )
{
// initializes and finds value for perimeter
int perimeter = (l+w) * 2;
// returns value of perimeter
return perimeter;
}
//finds the area of the rectangle
public double area( int l, int w )
{
//initializes area and finds the value
int area = ( l * w);
// returns area
return area;
}
//outputs final math
public void processRectangle()
{
// this prints out the results..
// perimeter() and area() not working??
System.out.printf( "\n%s %d\n%s %d\n\n",
" The perimeter of the rectangle is: ", perimeter( int l, int w ),
" The area of the rectangle is: ", area( int l, int w ) );
}
}
//
import java.util.Scanner;
public class RectangleTest
{
public static void main ( String[] args )
{
//Scanner for input
Scanner input = new Scanner( System.in );
Rectangle myRectangle = new Rectangle( int l, int w );
//inputs lenght
System.out.println( " Please enter the lenght: ");
int lenght = input.nextLine();
System.out.println();
//inputs width
System.out.println( " Please enter the width: ");
int width = input.nextLine();
System.out.println();
}
}