zoukankan      html  css  js  c++  java
  • scanner04

    package com.lyc;
    import java.util.Scanner;

    public class Demo04 {
    public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    //从键盘接收数据
    int i = 0;
    float f = 0.0f;
    System.out.println("请输入整数:");

    if (scanner.hasNextInt()){
    i = scanner.nextInt();
    System.out.println("整数数据"+ i);
    }else {
    System.out.println("输入的不是整数数据!");
    }

    System.out.println("请输入小数:");

    if (scanner.hasNextFloat()){
    f = scanner.nextFloat();
    System.out.println("小数数据"+ f);
    }else {
    System.out.println("输入的不是小数数据!");
    }

    }
    }
  • 相关阅读:
    这几天都是在公司慢待
    电脑没有关机可能出现发博文dns异常(write)
    DOS/VBS
    SourceInsight
    CevaEclipse
    C/C++
    Matlab
    Matlab
    C语言
    Matlab
  • 原文地址:https://www.cnblogs.com/liuyunche/p/14241993.html
Copyright © 2011-2022 走看看