java1.12.3实验3(从键盘输入数据)Scanner工具类

import java.util.Scanner;
public class Test {
    public static void main(String[] args){
        int amount;
        float price , sum;
        Scanner input=new Scanner(System.in);
        System.out.print("please input the amount:");
        amount=input.nextInt();
        System.out.print("please input the price:");
        price=input.nextFloat();
        sum=price*amount;
        System.out.printf("amount:%d,   price:%5.2f,   sum:%5.2f",amount,price,sum);

    }
    
}

你可能感兴趣的:(Java)