import.awt.Rectangle;

public class AreaTester
{
	public static void main(String[] args)
	{
		Rectangle R = new Rectangle(5,6,7,8);
		System.out.print("w: ");
		int w = R.getWidth();
		System.out.println(box.getWidth());

		System.out.print("h: ");
		int h = R.getHeight();
		System.out.println(box.getHeight());
		int area = w*h;
		System.out.println("Area of Rectangle:"+ area);

	}
}

The above code gives error:<identifier> expected
import.awt.Rectangle;
^

import java.awt.Rectangle;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

public class AreaTester
{
	public static void main(String[] args)
	{
		Rectangle R = new Rectangle(5,6,7,8);
		System.out.print("w: ");
		double w = R.getWidth();
		System.out.println(box.getWidth());

		System.out.print("h: ");
		double h = R.getHeight();
		System.out.println(box.getHeight());
		double area = w*h;
		System.out.println("Area of Rectangle:"+ area);

	}
}

Errors:
cannot find symbol
System.out.println(box.getWidth());
^
symbol: variable box
location: class AreaTester
cannot find symbol
System.out.println(box.getHeight());
^
symbol: variable box
location: class AreaTester
2 errors

This article has been dead for over six months. Start a new discussion instead.