输入数据

来源:互联网 发布:长春知水江南临河街店 编辑:程序博客网 时间:2024/06/10 02:44
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. *//** * * @author lenovo */import java. util.Scanner;public class InpData {    public static void main(String args[]){        Scanner reader=new Scanner(System.in);//创建对象        int amount=0;        float price=0,sum=0;        System.out.println("please input produce's  number:");        amount=reader.nextInt();//输入数量        System.out.println("please inpput price:");        price=reader.nextFloat();//输入价格        sum=price*amount;//计算        System.out.printf("number:%d,price:%5.2f,sum:%5.2f",amount,price,sum);    }        }

0 0
原创粉丝点击