在我的扫描仪上找不到符号

时间:2014-10-31 19:35:36

标签: java find symbols

尝试创建一个程序,允许您输入图片框和图片的长度/宽度,然后比较两者以查看是否适合另一个。简单的东西,因为我是Java新手,但我离题了 - 这里是代码:

import java.util.Scanner;

public class pictureFrame {
   public static void main(String[] args) {
      double x = 0;
      double y = 0;
      double u = 0;
      double v = 0;

      xScanner = new Scanner(System.in);
      yScanner = new Scanner(System.in);
      uScanner = new Scanner(System.in);
      vScanner = new Scanner(System.in);

      System.out.println("Enter the length of the picture");
      x = xScanner.nextDouble();
      System.out.println("Enter the width of the picture");
      y = yScanner.nextDouble();
      System.out.println("Enter the length of the frame");
      u = uScanner.nextDouble();
      System.out.println("Enter the width of the frame");
      v = vScanner.nextDouble();

      if (x = u && y = v)
      {
        System.out.println("The frame fits the picture!");
      }
        else if (x == v && y == u) 
        {
            System.out.println("The frame fits the picture!");
        } 
               else 
              {
                  System.out.println("The frame does not fit the picture");
              }

         }

     }
     }

我得到8个错误,所有声明他们找不到以下每行的第一个字符的符号:

  xScanner = new Scanner(System.in);
  yScanner = new Scanner(System.in);
  uScanner = new Scanner(System.in);
  vScanner = new Scanner(System.in);
  x = xScanner.nextDouble();
  y = yScanner.nextDouble();
  u = uScanner.nextDouble();
  v = vScanner.nextDouble();

很抱歉,如果这个问题很愚蠢,我确实事先使用了搜索功能。

1 个答案:

答案 0 :(得分:2)

您忘记将Scanner放在声明前面,也只是..您只需要声明一次扫描程序:

Scanner scan = new Scanner(System.in);
x = scan.nextDouble();
y = scan.nextDouble();
//etc..