import java.util.Scanner;
public class helloworld{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
try {
int a = (int)(Math.random() * 12);
int b = (int)(Math.random() * 12);
int c = (int)(Math.random() * 12);
System.out.println("What is the sum of " + a + " + " + b + " + " + c + " ?");
System.out.print("Enter the sum of three numbers: " );
int sum = input.nextInt();
if(a + b + c ==sum) {
System.out.println("The answer is ture!");
}
else
System.out.println("The answer is fasle");
}finally {
input.close();
}
}
}
判断随机三个数相加的正确性
最新推荐文章于 2023-03-10 14:14:03 发布