编写Java程序,显示五个加减法测验的正确率和用时

本文介绍了如何使用Java编写一个程序,该程序提供五个加减法测验,并记录用户的答题正确率及完成测验所花费的时间,帮助用户了解自己的计算速度和准确度。
摘要由CSDN通过智能技术生成

代码如下:

package com.nfsbbs.test;

import java.util.Scanner;

public class MathsTest {
	
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        final int MAX = 20; 
        final int MUST_SOLVE = 5;
        int a, b;
        double crt = 0;
        double rate;
        
        double startTime, endTime;
        double sec;

        System.out.println("Maths Test\n");
        System.out.println("You need to correctly solve addition problems as quickly as you can. ");
        System.out.println("You must answer " + MUST_SOLVE + " correctly before the test will end. ");
        System.out.println("The operand values will be between 1 and " + MAX + ". \n");
        System.out.println("Press ENTER to start the test. ");
        
        sc.nextLine();
        startTime = System.currentTimeMillis();
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值