简单的博客项目

来源:互联网 发布:英虎网络股份有限公司 编辑:程序博客网 时间:2024/05/22 09:02
/**
 *购系统物
 *@author 
 *
 */


public class Shopping {
    public static void main (String [] args) {
int a;   //存放用户输入的购买数量
int b;   //存放需要的付款金额
int c;   //存放用户输入的付款数额;
int d;   //存放找零数额


        System.out.println("\t\t 购物管理系统 ");
System.out.println("* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  ");
System.out.println("商品名称 \t 商品价格 \t 商品描述");
System.out.println("小米手机3 \t ¥1999 \t 小米手机,手机中的战斗机");


System.out.println("* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  ");


System.out.println("请输入购买数量");
//接受用户输入
java.util.Scanner input1 = new java.util.Scanner(System.in);
        a = input1.nextInt();


b = a * 1999;  //需要支付的金额




System.out.println("尊敬的用户,您购买的商品信息如下:");
System.out.println("商品名称:小米手机3S");
System.out.println("商品单价:¥1999");
System.out.println("购买数量:" + a);
System.out.println("需要付款:"+ a +"*" + "1999" + "=" + b);




System.out.println("请输入付款总数");
//接受用户输入付款金额
java.util.Scanner input2 = new java.util.Scanner(System.in);
        c = input2.nextInt();
             
        d = c - b;     //需要找零的数额




if(c >= b){
   System.out.println("尊敬的用户,您已购买的商品信息如下:");
   System.out.println("商品名称:小米手机3S");
   System.out.println("商品单价:¥1999");
   System.out.println("购买数量:" + a);
   System.out.println("付款:"+ a +"*" + "1999" + "=" + b);
   System.out.println("找零:"+ c + "-" + b + "=" + d);


        } else {
   System.out.println("对不起,您的资金不足。。。");


        }    




    }
}
0 0
原创粉丝点击