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);
}
}


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

posted @ 2011-12-03 17:31  馨梦域名主机服务中心  阅读(105)  评论(0编辑  收藏  举报
官方推出免费静态网页空间,适合大企业展示和个人展示类空间。欢迎联系QQ908898668申请。