集册 Java实例教程 读取整数值

读取整数值

欢马劈雪     最近更新时间:2020-01-02 10:19:05

562
读取整数值

import java.util.Locale;

import java.util.Scanner;


public class Main {
/**
 * N o  w  J a v a . c o m - 时  代  Java 提 供 
**/

    public static void main(String[] args) {

        Scanner keyboard = new Scanner(System.in);

        keyboard.useLocale(Locale.UK);


        int val;

        double vald;

        double valf;


        System.out.print("Enter an integer please:");

        val = keyboard.nextInt();
        /* 
         来自 
        *时代Java - N o w  J a v a . c o m*/

        System.out.print("I read the following value:");

        System.out.println(val);


        System.out.print("Enter a float please:");

        valf = keyboard.nextFloat();

        System.out.print("I read the following value:");

        System.out.println(valf);


        System.out.
展开阅读全文