博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
java 初探-猜数字
阅读量:4480 次
发布时间:2019-06-08

本文共 843 字,大约阅读时间需要 2 分钟。

学习Java而编写的猜数字的程序代码。

/** *  */package org.literal.test;import java.util.Scanner;/** * @author literal kernel * */public class Main {    /**     * @param args     */    public static void main(String[] args) {        // TODO 自动生成的方法存根        Scanner input = new Scanner(System.in);        // generate random number        int num = (int) (Math.random() * 100.0);                int guess;        do        {            System.out.println("请猜测:");            guess = input.nextInt();            if(guess < num)            {                System.out.println("小了");            }            if(guess>num)            {                System.out.println("大了");            }        }while(guess != num);                // guess it!        System.out.println("猜对了!");                input.close();    }}

 

转载于:https://www.cnblogs.com/sinx/p/11046436.html

你可能感兴趣的文章
UIResponder学习
查看>>
redis 主从服务器
查看>>
设计模式完结(6)--适配器模式----不兼容结构的协调
查看>>
关于Aspose强大的应用--EXECL
查看>>
课堂final发布
查看>>
解锁scott用户
查看>>
多态的理解
查看>>
AspNet Core 发布到Linux系统和发布IIS 注意项
查看>>
Windows添加.NET Framework 3.0 NetFx3 失败 - 状态为:0x800f0950
查看>>
隐藏显示终端的光标(shell echo,linux c printf)
查看>>
SQL Server 存储过程
查看>>
JSP 标准标签库(JSTL)(JSP Standard Tag Library)
查看>>
导入项目遇到的问题: Some projects cannot be imported because they already exist in the workspace....
查看>>
华为:字符集合
查看>>
面向对象 【抽象类】【接口】【构造函数】【静态】
查看>>
结构化方法与面向对象方法的比较
查看>>
影响各类服务器性能瓶颈的因素【转】
查看>>
Jenkins
查看>>
jboss5 启动时报HsqlException:length must be specified in type definition:VARBINARY错误
查看>>
转载:让理科生沉默,让文科生流泪的综合题
查看>>