java课堂笔记 嵌套循环

//要求控制台输入是否是会员的标志(y/n)。y是会员,n不是会员。和消费金额
//是会员。金额大于100大九折,大于200打八折,否则不打折
//不是会员,金额大于200打九折,否则不打折
Scanner input=new Scanner(System.in);
System.out.println(“请输入消费金额:”);
double j=input.nextDouble();
System.out.println(“请输入是否是会员y/n:”);
char hy=input.next().charAt(0);

	if(hy=='y'){
		System.out.println("是会员");
		if(j>100){
			System.out.println("打九折");
			}else if(j>200){
				System.out.println("打八折");
			}else{
				System.out.println("不打折");
			}
		}else{
		System.out.println("不是会员");
		if(j>200){
			System.out.println("打九折");
		}else{
			System.out.println("不打折");
		}
	}

猜你喜欢

转载自blog.csdn.net/sangmojiu/article/details/88950610