1、程序概述:
在idea中通过代码运行随机生成数学题并显示,用户在做完一道题便可得知对错,直到题做完为止,若不想继续计算还可强制停止运行
2、代码展示
package com.day01.day05;
import java.util.Scanner;
public class Practice {public static void main(String[] args) {//随机数学题Scanner scan = new Scanner(System.in);int score = 0;//得分for (int i = 1; i <= 10; i++) {int a = (int) (Math.random() * 100);int b = (int) (Math.random() * 100);int result = a + b;System.out.println("(" + i + ")" + a + "+" + b + "=?");//出题System.out.println("算");
本文发布于:2024-02-02 07:55:47,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170683174842420.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |