该程序的目标是测试键盘输入的整数值是否等于176.如果是,则打印“YES”(不带引号)。
import java.util.Scanner;
public class Lesson_11_Activity_One {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println(" Please enter a number :");
int number = input.nextInt();
if(number == 176)
{
System.out.println("Yes");
}
}
}
输出结果显示:
Your code has been evaluated against a set of test data.
You had 4 out of 5 tests pass correctly.
Double check your results in drJava and if you can't see what's wrong,
don't hesitate to start a post on Piazza.
Test 1, Decimal input but not 48.729: Passed!
Test 2, Decimal input but not 48.729: Passed!
Test 3, Decimal input but not 48.729: Passed!
Test 4, Integer input but not 48.729: Passed!
不确定问题似乎是什么。
答案 0 :(得分:1)
作业要求你打印"是"没有引号。在你的程序中它只打印出来"是"代码没有问题,问题是你正在打印"是"当它要求"是"只需改变"是"到"是"