标签:
本数 折扣
2 5%
3 10%
4 20%
5 25%
import java.util.*; import javax.swing.*; public class Haripoter { public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("请输入购买数量(本):"); Scanner sca = new Scanner(System.in); int num = sca.nextInt(); double price = 0; System.out.println("总价为:"); if(num%8==0) { price = (num/8)*51.2; System.out.println(price+"元"); } if(num%8==1) { price = (num/5)*30+8; System.out.println(price+"元"); } if(num%8==2) { price = (num/5)*30+15.2; System.out.println(price+"元"); } if(num%8==3) { price = (num/5)*30+21.6; System.out.println(price+"元"); } if(num%8==4) { price = (num/5)*30+25.6; System.out.println(price+"元"); } if(num%8==5) { price = (num/5)*30+30; System.out.println(price+"元"); } if(num%8==6) { price = (num/5)*30+38; System.out.println(price+"元"); } if(num%8==7) { price = (num/5)*30+45.2; System.out.println(price+"元"); } } }
结果截图:
标签:
原文地址:http://www.cnblogs.com/xiaosongbiog/p/5557718.html