1

コードの何が問題になっていますか? スキャナー部分にエラーがあります。「詳細を追加する必要があります4この質問を投稿できるので、これで終わりです。

import java.util.Scanner
class rectangle
{
  double width;
  double length;
  double findArea(double a, double b)
  {
    width=a;
    length=b;
    return a*b;
  }
}
public class area
{
  public static void main(String args[])
  {
    {
      System.out.println("Enter the dimensions of the square.");
      Scanner x = new Scanner(System.in);
      Scanner y = new Scanner(System.in);
    }
    {
      rectangle objrect = new rectangle();
      System.out.println(objrect.findArea(x, y));
    }
  }
}
4

2 に答える 2

0

Replace the x and y value input line with follows:

Scanner s = new Scanner(System.in);
double x = s.nextDouble();
double y = s.nextDouble();

Now call the method finaArea as follows:

objrect.findArea(x, y)
于 2013-08-09T22:51:01.543 に答える