package Arryay;
import java.util.Scanner;
public class Out {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("====请选择要购买的商品====");
System.out.println("====1、T恤 ====");
System.out.println("====2、手机 ====");
System.out.println("====3、电脑 ====");
Scanner sc=new Scanner(System.in);
int num_goods=sc.nextInt();
switch (num_goods) {
case 1:
System.out.println("====请选择品牌 ====");
System.out.println("====1、阿迪 ====");
System.out.println("====2、耐克 ====");
System.out.println("====3、李宁 ====");
int num_brand=sc.nextInt();
int num_confirm;
do {
int price;
System.out.println("====请确认价格 ====");
if(num_brand==1){
price=(int) Math.round(300*0.95);
System.out.println("====您购买的阿迪牌T恤的价格为:"+price+"元 ====");
}else if(num_brand==2){
price=(int) Math.round(200*0.85);
System.out.println("====您购买的耐克的价格为:"+price+"元 ====");
}else if(num_brand==3){
price=(int) Math.round(125*0.72);
System.out.println("====您购买的李宁的价格为:"+price+"元 ====");
}
System.out.println("====1、购买 ====");
System.out.println("====0、取消 ====");
num_confirm=sc.nextInt();
if(num_confirm==1){
System.out.println("====恭喜您购买成功! ====");
System.out.println("拜拜!");
System.out.println("结束购物");
break;
}else if(num_confirm==0){
System.out.println("====请选择品牌 ====");
System.out.println("====1、阿迪 ====");
System.out.println("====2、耐克 ====");
System.out.println("====3、李宁 ====");
num_brand=sc.nextInt();
}else{
System.out.println("输入错误!!!");
}
} while (num_confirm==1||num_confirm==0);
break;
case 2:
System.out.println("====请选择品牌 ====");
System.out.println("====1、苹果 ====");
System.out.println("====2、小米 ====");
System.out.println("====3、 华为 ====");
int num_brand2=sc.nextInt();
int num_confirm2;
do {
int price2;
System.out.println("====请确认价格 ====");
if(num_brand2==1){
price2=(int) Math.round(6100*0.87);
System.out.println("====您购买的苹果的价格为:"+price2+"元 ====");
}else if(num_brand2==2){
price2=(int) Math.round(899*0.92);
System.out.println("====您购买的小米的价格为:"+price2+"元 ====");
}else if(num_brand2==3){
price2=(int) Math.round(1999*0.92);
System.out.println("====您购买的华为的价格为:"+price2+"元 ====");
}
System.out.println("====1、购买 ====");
System.out.println("====0、取消 ====");
num_confirm2=sc.nextInt();
if(num_confirm2==1){
System.out.println("====恭喜您购买成功! ====");
System.out.println("拜拜!");
System.out.println("结束购物");
break;
}else if(num_confirm2==0){
System.out.println("====请选择品牌 ====");
System.out.println("====1、苹果 ====");
System.out.println("====2、小米 ====");
System.out.println("====3、华为 ====");
num_brand2=sc.nextInt();
}else{
System.out.println("输入错误!!!");
}
} while (num_confirm2==1||num_confirm2==0);
break;
case 3:
System.out.println("====请选择品牌 ====");
System.out.println("====1、惠普 ====");
System.out.println("====2、联想 ====");
System.out.println("====3、华硕 ====");
int num_brand3=sc.nextInt();
int num_confirm3;
do {
int price3;
System.out.println("====请确认价格 ====");
if(num_brand3==1){
price3=(int) Math.round(8900*0.95);
System.out.println("====您购买的惠普的价格为:"+price3+"元 ====");
}else if(num_brand3==2){
price3=(int) Math.round(4998*0.90);
System.out.println("====您购买的联想的价格为:"+price3+"元 ====");
}else if(num_brand3==3){
price3=(int) Math.round(4998*0.80);
System.out.println("====您购买的华硕的价格为:"+price3+"元 ====");
}
System.out.println("====1、购买 ====");
System.out.println("====0、取消 ====");
num_confirm3=sc.nextInt();
if(num_confirm3==1){
System.out.println("====恭喜您购买成功! ====");
System.out.println("拜拜!");
System.out.println("结束购物");
break;
}else if(num_confirm3==0){
System.out.println("====请选择品牌 ====");
System.out.println("====1、惠普 ====");
System.out.println("====2、联想 ====");
System.out.println("====3、华硕 ====");
num_brand3=sc.nextInt();
}else{
System.out.println("输入错误!!!");
}
} while (num_confirm3==1||num_confirm3==0);
break;
default:
break;
}
}
}
import java.util.Scanner;
public class Out {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("====请选择要购买的商品====");
System.out.println("====1、T恤 ====");
System.out.println("====2、手机 ====");
System.out.println("====3、电脑 ====");
Scanner sc=new Scanner(System.in);
int num_goods=sc.nextInt();
switch (num_goods) {
case 1:
System.out.println("====请选择品牌 ====");
System.out.println("====1、阿迪 ====");
System.out.println("====2、耐克 ====");
System.out.println("====3、李宁 ====");
int num_brand=sc.nextInt();
int num_confirm;
do {
int price;
System.out.println("====请确认价格 ====");
if(num_brand==1){
price=(int) Math.round(300*0.95);
System.out.println("====您购买的阿迪牌T恤的价格为:"+price+"元 ====");
}else if(num_brand==2){
price=(int) Math.round(200*0.85);
System.out.println("====您购买的耐克的价格为:"+price+"元 ====");
}else if(num_brand==3){
price=(int) Math.round(125*0.72);
System.out.println("====您购买的李宁的价格为:"+price+"元 ====");
}
System.out.println("====1、购买 ====");
System.out.println("====0、取消 ====");
num_confirm=sc.nextInt();
if(num_confirm==1){
System.out.println("====恭喜您购买成功! ====");
System.out.println("拜拜!");
System.out.println("结束购物");
break;
}else if(num_confirm==0){
System.out.println("====请选择品牌 ====");
System.out.println("====1、阿迪 ====");
System.out.println("====2、耐克 ====");
System.out.println("====3、李宁 ====");
num_brand=sc.nextInt();
}else{
System.out.println("输入错误!!!");
}
} while (num_confirm==1||num_confirm==0);
break;
case 2:
System.out.println("====请选择品牌 ====");
System.out.println("====1、苹果 ====");
System.out.println("====2、小米 ====");
System.out.println("====3、 华为 ====");
int num_brand2=sc.nextInt();
int num_confirm2;
do {
int price2;
System.out.println("====请确认价格 ====");
if(num_brand2==1){
price2=(int) Math.round(6100*0.87);
System.out.println("====您购买的苹果的价格为:"+price2+"元 ====");
}else if(num_brand2==2){
price2=(int) Math.round(899*0.92);
System.out.println("====您购买的小米的价格为:"+price2+"元 ====");
}else if(num_brand2==3){
price2=(int) Math.round(1999*0.92);
System.out.println("====您购买的华为的价格为:"+price2+"元 ====");
}
System.out.println("====1、购买 ====");
System.out.println("====0、取消 ====");
num_confirm2=sc.nextInt();
if(num_confirm2==1){
System.out.println("====恭喜您购买成功! ====");
System.out.println("拜拜!");
System.out.println("结束购物");
break;
}else if(num_confirm2==0){
System.out.println("====请选择品牌 ====");
System.out.println("====1、苹果 ====");
System.out.println("====2、小米 ====");
System.out.println("====3、华为 ====");
num_brand2=sc.nextInt();
}else{
System.out.println("输入错误!!!");
}
} while (num_confirm2==1||num_confirm2==0);
break;
case 3:
System.out.println("====请选择品牌 ====");
System.out.println("====1、惠普 ====");
System.out.println("====2、联想 ====");
System.out.println("====3、华硕 ====");
int num_brand3=sc.nextInt();
int num_confirm3;
do {
int price3;
System.out.println("====请确认价格 ====");
if(num_brand3==1){
price3=(int) Math.round(8900*0.95);
System.out.println("====您购买的惠普的价格为:"+price3+"元 ====");
}else if(num_brand3==2){
price3=(int) Math.round(4998*0.90);
System.out.println("====您购买的联想的价格为:"+price3+"元 ====");
}else if(num_brand3==3){
price3=(int) Math.round(4998*0.80);
System.out.println("====您购买的华硕的价格为:"+price3+"元 ====");
}
System.out.println("====1、购买 ====");
System.out.println("====0、取消 ====");
num_confirm3=sc.nextInt();
if(num_confirm3==1){
System.out.println("====恭喜您购买成功! ====");
System.out.println("拜拜!");
System.out.println("结束购物");
break;
}else if(num_confirm3==0){
System.out.println("====请选择品牌 ====");
System.out.println("====1、惠普 ====");
System.out.println("====2、联想 ====");
System.out.println("====3、华硕 ====");
num_brand3=sc.nextInt();
}else{
System.out.println("输入错误!!!");
}
} while (num_confirm3==1||num_confirm3==0);
break;
default:
break;
}
}
}