2. 编写程序,使它产生10个随机数加法问题,加数是1到15之间的整数,让用户输入答案后验证用户的答案是否正确,每答对一题得10分,统计并最后输出用户得分(原题)package pro2;import java.util.Random;import java.util.*;public class Dome_4 { public static void main(String[] args) { // TODO Auto-generated method stub int grade = 0; Scanner input = new Scanner(System.in); System.out.println("请输入答案"); int s = input.nextInt(); Random r = new Random(); int a = r.nextInt(15); Random r1 = new Random(); int arr[] = new int[10]; for (int i = 0; i < arr.length; i++) { arr[i] = r1.nextInt(15); if (s = arr[i] + a) { System.out.println("恭喜你做对了" + grade + 10); } } }}
添加回答
举报
0/150
提交
取消