I am writing a 2-part program, a main program and a test program that figures the area and perimeter of a rectangle from an users input. I have my main program with no compile errors, but my test program has a couple errors and they both have to do with a method call to the main program. If someone could give me a little help I would appreciate it greatly.

here is the main program

public class Rectangle
{
	//set default parameters to 1
	private double width;
	private double length;
	private double perimeter;
	private double area;

	public Rectangle( double theLength, double theWidth )
	{
		setLength( theLength );
		setWidth( theWidth );
	}//end Rectangle two-argument constructor

	//validate and set length
	public void setLength( double theLength )
	{
		length = ( theLength> 0.0 && theLength < 20.0 ? theLength : 1.0 );
	}//end method setLenght

	//validate and set width
	public void setWidth( double theWidth )
	{
		width = ( theWidth > 0.0 && theWidth < 20.0 ? theWidth : 1.0 );
	}//end method width

	//Get methods
	//get length value

	public int getLength()
	{
		return (int) length;
	}//end method getLength

	//get width value
	public int getWidth()
	{
		return (int) width;
	}//end method getWidth

	//calculate area

	public double rectangleArea( double width, double length)
	{
		area = ( length * width );
		return area;
	}//end method recatngelArea

	//calculate perimeter

	public double rectanglePerimeter(double width, double length)
	{
		perimeter = ( (2 * width) + (2 * length) );
		return perimeter;
	}//end method rectanglePerimeter

	//convert to string
	public String toPerimeterString()
	{
		return String.format( "%02d", perimeter);
	}//end method toMyAreaString

	public String toMyAreaString()
	{
		return String.format( "%02d", area );
	}//end method toMyAreaString



}//end class Rectangle

here is the test program--

import java.util.Scanner;//program uses scanner

public class RectangleTest1
{
	public static void main( String args[] )
	{
		Scanner input = new Scanner (System.in);
		int answer;//user input answer
		int width;//user inputs width
		int length;//user inputs length

		Rectangle myRectangle = Rectangle();

		System.out.println ( "Enter the data for your rectangle:\n\n\n" );

		System.out.println ( "Enter the width from 1 to 20  ( defaults to 1 ) :  " );
		width = input.nextInt();

		System.out.println ( "Enter the length from 1 to 20 (defaults to 1 ) : " );
		length = input.nextInt();

		System.out.println ( "\n\n\nEnter 1 to find Area" );
		System.out.println ( "Enter 2 to find Perimeter" );
		System.out.println ( "Enter 0 to quit" );

		answer = input.nextInt();

		while ( answer != 0 )
		{
			if (answer == 1 )
			{
				System.out.println ( "   %s", Rectangle.rectangleArea() );

			}//end if

			if ( answer == 2 )
			{
				System.out.println ( "   %s", Rectangle.rectanglePerimeter() );

			}//end if


		}//end while

	}//end method main

}//end class RectangleTest1

here is my errors--

\RectangleTest1.java:17: cannot find symbol
symbol : method Rectangle()
location: class RectangleTest1
Rectangle myRectangle = Rectangle();
^
\RectangleTest1.java:37: rectangleArea(double,double) in Rectangle cannot be applied to ()
System.out.println ( " %s", Rectangle.rectangleArea() );
^
\RectangleTest1.java:43: rectanglePerimeter(double,double) in Rectangle cannot be applied to ()
System.out.println ( " %s", Rectangle.rectanglePerimeter() );
^
3 errors

Rectangle myRectangle = Rectangle(); should be Rectangle myRectangle = [B]new[/B] Rectangle(); The second too, I suggest you look at the function. Notice you declare them as taking two parameters yet you call them with 0.

Chris

when I put keyword new in front of my Rectangle(). It still gives me the same errors just moves the carrot under the work new.

Take a look at the constructor you wrote for Rectangle and compare that to the code you are using to create it (which you are doing when you add the "new" keyword). You have collected the info to use that constructor, you just aren't doing so.

This question has already been answered. Start a new discussion instead.