1.第一个java程序

public class Main {
public static void main(String[] args){
int shirtPrice=245;//Tshirt价格
int shoePrice =570;//网球鞋价格
int padPrice=320;//拍子的价格
int shirtNo=2;//T恤衫数量
int shoeNo=1;
int padNo=1;
double discount=0.8;//折扣,这个discount用来下面乘。
/*计算消费总金额 */
double finalPay=(shirtPrice*shirtNo + shoePrice*shoeNo+padPrice*padNo)*discount;
double zl=(1500 - finalPay);
int jifen= (int) (finalPay *3 / 100);//准备输出
System.out.println("*********消费单*********");
System.out.println("购买物品"+"\t"+"单价(¥)"+"\t"+"个数"+"\t"+"金额");
System.out.println("T恤衫 "+"\t¥"+shirtPrice+" \t"+shirtNo+" \t"+shirtPrice*shirtNo);
System.out.println("网球鞋 "+"\t¥"+shoePrice+" \t"+shoeNo+" \t"+shoePrice*shoeNo);
System.out.println("拍子 "+"\t¥"+padPrice+" \t"+padNo+" \t"+padPrice*padNo+" \n");
System.out.println("折扣"+" \t"+discount*10+"折");
System.out.println("消费总金额:"+" \t¥"+finalPay);
System.out.println("顾客付款:1500,找零"+ zl);
System.out.println("本次购物获得积分:"+jifen);
}
}


写的第一个程序,刚才不知道为什么没有发布成功~

原文地址:https://www.cnblogs.com/qobin/p/2274836.html