【发布时间】:2014-12-28 05:11:25
【问题描述】:
尝试创建一个程序,允许您输入相框和图片的长度/宽度,然后比较两者以查看一个是否适合另一个。简单的东西,因为我是 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();
对不起,如果这个问题很愚蠢,我确实事先使用了搜索功能。
【问题讨论】: