package day01;
//JAVA day01
import java.util.Scanner;
public class Demo03 {
/*
编写收银台小程序,输入个数,单价,金额,输出找零。
满100打95折;
满300打90折;
满500打85折;
*/
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("请输入个数:");
int mount = scanner.nextInt();
System.out.println("请输入单价:");
float price = scanner.nextFloat();
System.out.println("请输入金额:");
float amount = scanner.nextFloat();
float pay = mount * price;
if(pay >= 500){ // 满500,pay >=500
pay = pay * 0.85f;
}else if(pay >= 300){
pay *= 0.9;
}else if(pay >= 100){
pay *= 0.95;
}
float change = amount - pay;
System.out.println("找零:" + change);
}
}
#python day01
mount = int(input("请输入个数:"))
price = int(input("请输入单价:"))
amount = int(input("请输入金额:"))
pay = mount * price
if pay >= 500 :
pay = pay * 0.85
elif pay >= 300 :
pay = pay * 0.9
elif pay >= 100 :
pay = pay * 0.95
change = amount - pay
if change >= 0 :
print("找零:", change)
else :
print("欠费:", change)
标签:JAVA,scanner,PYTHON,pay,day01,System,500,输入,change From: https://www.cnblogs.com/zhao02/p/17809366.html