尝试解答一下,这个里面还有老年和教师的判断就省略,主要是打折的代码
import java.util.Scannerclass Test{
public static void main (String[] args){
Scanner sc = new Scanner(System.in)
System.out.println("请输入消费的金额:")
double oldprice = sc.nextDouble()
double newprice
if(oldprice >= 2000){
newprice = oldprice * 春笑0.85
}else if(oldprice >= 1000 && oldprice < 2000){
伍做 newprice = oldprice * 0.9
}else
newprice = oldprice
Judge jud = new Judge()
if(jud.isTeacher()|| jud.isOldman())
newprice = newprice * 0.95
System.out.println("打折后的价格是:" + newprice)
System.out.println("折扣的程度是: " + newprice / oldprice)
}
}
class Judge{
public boolean isTeacher(){
boolean isTeacher = false
return isTeacher
}
public boolean isOldman(){
boolean isOld = false
腔森衡 return isOld
}
}
public static void main(String[] args) {// 消费金额
int 陆雹amount = 0
if(amount >= 800) {
System.out.println("打6折")
铅纤}
else if(amount >= 600) {
System.out.println("打7折")
}
else if(amount 早激帆>= 400) {
System.out.println("打8折")
}
else if(amount >= 200) {
System.out.println("打9折")
}
else {
System.out.println("不打折")
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)