A商品69元,买二送一;即买3个商品,付2件钱,小于3件时,按原价购买。

问题:
A商品69元,买二送一;即买3个商品,付2件钱,小于3件时,按原价购买。
B商品88元,大于等于5件时,价格为80元;
C商品128元,大于等于3件时,价格100元;
同时购买三个商品时,优惠只能三选二。
总优惠:
1.当商品总数量大于等于10个时,减免全部商品中最低价的一件。
2.当商品价格大于1000时,减免100元;二种优惠选一种。用编程实现买家最低价格的计算;

package com.test.Ms1;
public class Demo1 {	int price;
	public int A(int Anum) {		
	int a = Anum / 3;	
	int b = Anum % 3;	
	int price1 = a * 2 * 69;	
         int price2 = b * 69;	
	price =price1+price2;
	return price;
	}
	public int B(int Bnum) {		
	if (Bnum >= 5) {			
	price = Bnum * 80;		
	}else{		
	price = Bnum * 88;
	}		
	return price;
	}
	public int C(int Cnum) {	
	if (Cnum >= 3) {			
	price = Cnum * 100;		
	}else{		
	price = Cnum * 128;		
	}		
	return price;	}
	public int zh(int A, int B, int C) {
	//price = A(A) + B(B) + C(C);	
	int price1 =A(A)+B(B)+C*128;	
	int price2 =A(A)+B*88+C(C);	
	int price3=69*A+B(B)+C(C);		
	price=(price1>price2?price2:price1)>price3?price3:(price1>price2?price2:price1);	
	System.out.println(price+" "+price1+" "+price2+" "+price3);		
	if ((A + B + C) >= 10 && price < 1000) {
			if (A > 0) {				
			price = price - 69;			
			} else if (B > 0) {				
			price = price - 88;
			} else if (C > 0) {				
			price = price - 128;			
			}		
			} else if (price >= 1000&&(A>0||B>0)) {			
			price = price - 100;		
			}		
			return price;	
			}
	public static void main(String[] args) {		
	       Demo1 demo1 = new Demo1();		
	System.out.println(demo1.zh(0, 0, 9));	
	}
}

如有错误望指正。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值