设为首页 加入收藏

TOP

梁勇Java语言程序设计第三章例题 作业
2017-10-11 15:22:48 】 浏览:2221
Tags:梁勇 Java 语言 程序设计 第三章 例题 作业

完成例题3-1,通过系统当前时间毫秒值获取随机10以内的整数判断加的结果是否正确,不用if语句

package com.swift;

import java.util.Scanner;

public class AdditionQuiz {

    public static void main(String[] args) {
        int number1=(int) (System.currentTimeMillis()%10);//从1970年1月1日开始到今天现在这个时刻的毫秒值
        int number2=(int) (System.currentTimeMillis()/7%10);//从1970年1月1日开始到今天现在这个时刻的毫秒值
        System.out.println(number1+"  .   "+number2);
        Scanner scan=new Scanner(System.in);
        System.out.println("what is"+number1+"+"+number2+"?");
        int answer=scan.nextInt();
        System.out.println(number1+"+"+number2+"="+answer+"is"+(number1+number2==answer));
        System.out.println(System.currentTimeMillis());
    }
}

 

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇读取xml文件中的配置参数 下一篇java.lang.OutOfMemoryError: Per..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目