星期六:完成了周末的作业
建立交易系统
package com.chainsoft.lianxi.AM; import java.util.Scanner; import java.util.Calendar; public class Lianxi1 { public static void main(String[] args) { // TODO Auto-generated method stub Scanner scan2 = new Scanner(System.in); //建立扫描器 System.out.print("欢迎卡号为1889977的会员登录,请输入密码:"); //建立登录系统 int mima = scan2.nextInt(); if(mima == 889977){ //if条件语句,来验证登录密码 Scanner scan3 = new Scanner(System.in); System.out.println("密码输入正确,正在核实积分请稍后"); double jifen = scan3.nextInt(); if(jifen<=500) //嵌套if语句,来判断会员等级 { System.out.println("欢迎白金会员进入"); }else if(jifen >500 & jifen <= 1000) { System.out.println("欢迎钻石会员进入"); }else if(jifen >= 1000) { System.out.println("欢迎至尊会员进入"); } Scanner scan = new Scanner(System.in); //建立扫描器 System.out.println("请输入所需的信息:0:主菜单丨1:购物车丨2:管理系统"); int a = scan.nextInt(); switch(a){ //用switch丨case条件语句进行选择 case 0: System.out.println("主菜单"); Scanner scan1 = new Scanner(System.in); //在条件语句里面再建立扫描器,进行选择 System.out.println("0:图书类丨1:电器类丨2:服装类丨3:母婴类:丨4:食品类"); int b = scan1.nextInt(); switch(b){ //在条件语句里再嵌套用switch丨case语句 case 0: System.out.println("文学丨童书丨教育丨人文社科丨经管丨艺术丨计算机丨科技丨生活"); Tushu a1 = new Zhizun(); //new一个新的对象来输出子类① ((Zhizun)a1).kucun(); ((Zhizun)a1).zhekou(); Tushu a2 = new Zuanshi(); //同① ((Zuanshi)a2).zhekou1(); Tushu a3 = new Baijin1(); //同① ((Baijin1)a3).zhekou2(); break; case 1: System.out.println("空调丨冰箱丨洗衣机丨电视丨热水器丨电风扇丨吸尘器"); Dianqi1 a11 = new Zhizun1(); //同① ((Zhizun1)a11).kucun(); ((Zhizun1)a11).zhekou(); Dianqi1 a12 = new Zuanshi1(); //同① ((Zuanshi1)a12).zhekou1(); Dianqi1 a13 = new Baijin11(); //同① ((Baijin11)a13).zhekou2(); break; case 2: System.out.println("短袖T恤丨长袖T恤丨休闲裤丨夹克丨衬衫丨牛仔裤丨短裤丨卫衣丨西装"); Fuzhuang1 aa = new Zhizun11(); //同① ((Zhizun11)aa).kucun(); ((Zhizun11)aa).zhekou(); Fuzhuang1 ab = new Zuanshi11(); //同① ((Zuanshi11)ab).zhekou1(); Fuzhuang1 ac = new Baijin111(); //同① ((Baijin111)ac).zhekou2(); break; case 3: System.out.println("奶粉丨尿裤湿巾丨洗护用品丨童车童床丨奶瓶丨奶嘴丨尿不湿"); Muying1 b1 = new Zhizun1a(); //同① ((Zhizun1a)b1).kucun(); ((Zhizun1a)b1).zhekou(); Muying1 b2 = new Zuanshi1a(); //同① ((Zuanshi1a)b2).zhekou1(); Muying1 b3 = new Baijin1a(); //同① ((Baijin1a)b3).zhekou2(); break; case 4: System.out.println("巧克力丨坚果丨茶丨咖啡丨饮料丨奶茶丨牛奶丨辣条丨糖果"); Shipin1 c1 = new Zhizun1b(); //同① ((Zhizun1b)c1).kucun(); ((Zhizun1b)c1).zhekou(); Shipin1 c2 = new Zuanshi1b(); //同① ((Zuanshi1b)c2).zhekou1(); Shipin1 c3 = new Baijin1b(); //同① ((Baijin1b)c3).zhekou2(); break; default: System.out.println("对不起,没有这个选项"); } break; case 1: System.out.println("购物车"); if(jifen>=1000){ //根据积分判断会员等级 Gouwu li = new Dingdan(); Tushu a1 = new Zhizun(); ((Zhizun)a1).kucun(); ((Zhizun)a1).zhekou(); Calendar c = Calendar.getInstance(); //购买商品的时间② int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH)+1; int date = c.get(Calendar.DATE); System.out.print(year +"-" + month + "-" + date); ((Dingdan)li).Lishi1(); Dianqi1 a11 = new Zhizun1(); //同① ((Zhizun1)a11).kucun(); ((Zhizun1)a11).zhekou(); Calendar d = Calendar.getInstance(); //同② int year1 = d.get(Calendar.YEAR)-1; int month1 =d.get(Calendar.MONTH)+6; int date1 = d.get(Calendar.DATE)+4; System.out.print(year1 +"-" + month1 + "-" + date1); ((Dingdan)li).Lishi2(); Fuzhuang1 aa = new Zhizun11(); //同① ((Zhizun11)aa).kucun(); ((Zhizun11)aa).zhekou(); Calendar e = Calendar.getInstance(); //同② int year2 = e.get(Calendar.YEAR); int month2 = e.get(Calendar.MONTH)-3; int date2 = e.get(Calendar.DATE)+5; System.out.print(year2 +"-" + month2 + "-" + date2); ((Dingdan)li).Lishi3(); Muying1 b1 = new Zhizun1a(); //同① ((Zhizun1a)b1).kucun(); ((Zhizun1a)b1).zhekou(); Calendar f = Calendar.getInstance(); //同② int year3 = f.get(Calendar.YEAR); int month3 = f.get(Calendar.MONTH); int date3 = f.get(Calendar.DATE)-11; System.out.print(year3 +"-" + month3 + "-" + date3); ((Dingdan)li).Lishi4(); Shipin1 c1 = new Zhizun1b(); //同① ((Zhizun1b)c1).kucun(); ((Zhizun1b)c1).zhekou(); Calendar g = Calendar.getInstance(); //同② int year4 = g.get(Calendar.YEAR); int month4 = g.get(Calendar.MONTH)+1; int date4 = g.get(Calendar.DATE)-15; System.out.print(year4 +"-" + month4 + "-" + date4); ((Dingdan)li).Lishi5(); }else if(jifen > 500 & jifen <=1000){ Gouwu li = new Dingdan(); Tushu a2 = new Zuanshi(); Tushu a1 = new Zhizun(); ((Zhizun)a1).kucun(); ((Zuanshi)a2).zhekou1(); Calendar c = Calendar.getInstance(); int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH)+1; int date = c.get(Calendar.DATE); System.out.print(year +"-" + month + "-" + date); ((Dingdan)li).Lishi1(); Dianqi1 a11 = new Zhizun1(); //同① ((Zhizun1)a11).kucun(); Dianqi1 a12 = new Zuanshi1(); //同① ((Zuanshi1)a12).zhekou1(); Calendar d = Calendar.getInstance(); int year1 = d.get(Calendar.YEAR); int month1 = d.get(Calendar.MONTH)+1; int date1 = d.get(Calendar.DATE); System.out.print(year1 +"-" + month1 + "-" + date1); ((Dingdan)li).Lishi2(); Fuzhuang1 aa = new Zhizun11(); //同① ((Zhizun11)aa).kucun(); Fuzhuang1 ab = new Zuanshi11(); //同① ((Zuanshi11)ab).zhekou1(); Calendar e = Calendar.getInstance(); int year2 = e.get(Calendar.YEAR); int month2 = e.get(Calendar.MONTH)+1; int date2 = e.get(Calendar.DATE); System.out.print(year2 +"-" + month2 + "-" + date2); ((Dingdan)li).Lishi3(); Muying1 b1 = new Zhizun1a(); //同① ((Zhizun1a)b1).kucun(); Muying1 b2 = new Zuanshi1a(); //同① ((Zuanshi1a)b2).zhekou1(); Calendar f = Calendar.getInstance(); int year3 = f.get(Calendar.YEAR); int month3 = f.get(Calendar.MONTH)+1; int date3 = f.get(Calendar.DATE); System.out.print(year3 +"-" + month3 + "-" + date3); ((Dingdan)li).Lishi4(); Shipin1 c1 = new Zhizun1b(); //同① ((Zhizun1b)c1).kucun(); Shipin1 c2 = new Zuanshi1b(); //同① ((Zuanshi1b)c2).zhekou1(); Calendar g = Calendar.getInstance(); int year4 = g.get(Calendar.YEAR); int month4 = g.get(Calendar.MONTH)+1; int date4 = g.get(Calendar.DATE); System.out.print(year4 +"-" + month4 + "-" + date4); ((Dingdan)li).Lishi5(); }else if(jifen <= 500){ Gouwu li = new Dingdan(); Tushu a1 = new Zhizun(); ((Zhizun)a1).kucun(); Tushu a3 = new Baijin1(); //同① ((Baijin1)a3).zhekou2(); Calendar c = Calendar.getInstance(); int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH)+1; int date = c.get(Calendar.DATE); System.out.print(year +"-" + month + "-" + date); ((Dingdan)li).Lishi1(); Dianqi1 a11 = new Zhizun1(); //同① ((Zhizun1)a11).kucun(); Dianqi1 a13 = new Baijin11(); //同① ((Baijin11)a13).zhekou2(); Calendar d = Calendar.getInstance(); int year1 = d.get(Calendar.YEAR); int month1 = d.get(Calendar.MONTH)+1; int date1 = d.get(Calendar.DATE); System.out.print(year1 +"-" + month1 + "-" + date1); ((Dingdan)li).Lishi2(); Fuzhuang1 aa = new Zhizun11(); //同① ((Zhizun11)aa).kucun(); Fuzhuang1 ac = new Baijin111(); //同① ((Baijin111)ac).zhekou2(); Calendar e = Calendar.getInstance(); int year2 = e.get(Calendar.YEAR); int month2 = e.get(Calendar.MONTH)+1; int date2 = e.get(Calendar.DATE); System.out.print(year2 +"-" + month2 + "-" + date2); ((Dingdan)li).Lishi3(); Muying1 b1 = new Zhizun1a(); //同① ((Zhizun1a)b1).kucun(); Muying1 b3 = new Baijin1a(); //同① ((Baijin1a)b3).zhekou2(); Calendar f = Calendar.getInstance(); int year3 = f.get(Calendar.YEAR); int month3 = f.get(Calendar.MONTH)+1; int date3 = f.get(Calendar.DATE); System.out.print(year3 +"-" + month3 + "-" + date3); ((Dingdan)li).Lishi4(); Shipin1 c1 = new Zhizun1b(); //同① ((Zhizun1b)c1).kucun(); Shipin1 c3 = new Baijin1b(); //同① ((Baijin1b)c3).zhekou2(); Calendar g = Calendar.getInstance(); int year4 = g.get(Calendar.YEAR); int month4 = g.get(Calendar.MONTH)+1; int date4 = g.get(Calendar.DATE); System.out.print(year4 +"-" + month4 + "-" + date4); ((Dingdan)li).Lishi5(); } break; case 2 : System.out.println("欢迎老板进入管理系统"); Scanner scan5 = new Scanner(System.in); //在条件语句里面再建立扫描器,进行选择 System.out.println("0:图书类丨1:电器类丨2:服装类丨3:母婴类:丨4:食品类"); int f = scan5.nextInt(); switch(f){ //在条件语句里再嵌套用switch丨case语句 case 0: System.out.println("文学丨童书丨教育丨人文社科丨经管丨艺术丨计算机丨科技丨生活"); Tushua a1 = new Zhizuna(); //new一个新的对象来输出子类① ((Zhizuna)a1).kucun(); ((Zhizuna)a1).zhekou(); ((Zhizuna)a1).lirun(); Tushua a2 = new Zuanshia(); //同① ((Zuanshia)a2).zhekou1(); ((Zuanshia)a2).lirun1(); Tushua a3 = new Baijin1aa(); //同① ((Baijin1aa)a3).zhekou2(); ((Baijin1aa)a3).lirun2(); break; case 1: System.out.println("空调丨冰箱丨洗衣机丨电视丨热水器丨电风扇丨吸尘器"); Dianqi1a a11 = new Zhizun1aa(); //同① ((Zhizun1aa)a11).kucun(); ((Zhizun1aa)a11).zhekou(); ((Zhizun1aa)a11).lirun(); Dianqi1a a12 = new Zuanshi1aa(); //同① ((Zuanshi1aa)a12).zhekou1(); ((Zuanshi1aa)a12).lirun1(); Dianqi1a a13 = new Baijin11a(); //同① ((Baijin11a)a13).zhekou2(); ((Baijin11a)a13).lirun2(); break; case 2: System.out.println("短袖T恤丨长袖T恤丨休闲裤丨夹克丨衬衫丨牛仔裤丨短裤丨卫衣丨西装"); Fuzhuang1a aa = new Zhizun11a(); //同① ((Zhizun11a)aa).kucun(); ((Zhizun11a)aa).zhekou(); ((Zhizun11a)aa).lirun(); Fuzhuang1a ab = new Zuanshi11a(); //同① ((Zuanshi11a)ab).zhekou1(); ((Zuanshi11a)ab).lirun1(); Fuzhuang1a ac = new Baijin111a(); //同① ((Baijin111a)ac).zhekou2(); ((Baijin111a)ac).lirun2(); break; case 3: System.out.println("奶粉丨尿裤湿巾丨洗护用品丨童车童床丨奶瓶丨奶嘴丨尿不湿"); Muying1a b1 = new Zhizun1a1(); //同① ((Zhizun1a1)b1).kucun(); ((Zhizun1a1)b1).zhekou(); ((Zhizun1a1)b1).lirun(); Muying1a b2 = new Zuanshi1a1(); //同① ((Zuanshi1a1)b2).zhekou1(); ((Zuanshi1a1)b2).lirun1(); Muying1a b3 = new Baijin1a1(); //同① ((Baijin1a1)b3).zhekou2(); ((Baijin1a1)b3).lirun2(); break; case 4: System.out.println("巧克力丨坚果丨茶丨咖啡丨饮料丨奶茶丨牛奶丨辣条丨糖果"); Shipin1a c1 = new Zhizun1b1(); //同① ((Zhizun1b1)c1).kucun(); ((Zhizun1b1)c1).zhekou(); ((Zhizun1b1)c1).lirun(); Shipin1a c2 = new Zuanshi1b1(); //同① ((Zuanshi1b1)c2).zhekou1(); ((Zuanshi1b1)c2).lirun1(); Shipin1a c3 = new Baijin1b1(); //同① ((Baijin1b1)c3).zhekou2(); ((Baijin1b1)c3).lirun2(); break; default: System.out.println("对不起,没有这个选项"); } break; default: System.out.println("对不起,没有这个选项"); } }else{ System.out.println("对不起,您输入的密码有误请核实后再输"); } } } class Tushu //建立一个父类表示会员对图书类商品的了解 { final double pjshoujia = 78.8; double zhekou; int kucun = 1324; } class Zhizun extends Tushu { double a = 0.5; void zhekou() { System.out.println("至尊会员对所有的图书都有:"+a+"的折扣"); } void kucun() { System.out.println("图书平均每种的库存为:"+kucun); System.out.println("每种图书的平均的销售价格为:"+pjshoujia); } } class Zuanshi extends Tushu { double a1 = 0.65; void zhekou1() { System.out.println("钻石会员对所有的图书都有:"+a1+"的折扣"); } } class Baijin1 extends Tushu { double a2 = 0.8; void zhekou2() { System.out.println("白金会员对所有的图书都有:"+a2+"的折扣"); } } class Dianqi1 //建立一个父类表示会员对电器类商品的了解 { final double pjshoujia = 3666; double zhekou; int kucun = 366; } class Zhizun1 extends Dianqi1 { double a11 = 0.6; void zhekou() { System.out.println("至尊会员对所有的电器都有:"+a11+"的折扣"); } void kucun() { System.out.println("电器平均每种的库存为:"+kucun); System.out.println("每种电器的平均的销售价格为:"+pjshoujia); } } class Zuanshi1 extends Dianqi1 { double a12 = 0.75; void zhekou1() { System.out.println("钻石会员对所有的电器都有:"+a12+"的折扣"); } } class Baijin11 extends Dianqi1 { double a22 = 0.8; void zhekou2() { System.out.println("白金会员对所有的电器都有:"+a22+"的折扣"); } } class Fuzhuang1 //建立一个父类表示会员对服装类商品的了解 { final double pjshoujia = 300; double zhekou; int kucun =6666; } class Zhizun11 extends Fuzhuang1 { double a12 = 0.6; void zhekou(){ System.out.println("至尊会员对所有的服装都有:"+a12+"的折扣"); } void kucun() { System.out.println("图服装平均每种的库存为:"+kucun); System.out.println("每种服装的平均的销售价格为:"+pjshoujia); } } class Zuanshi11 extends Fuzhuang1 { double a13 = 0.75; void zhekou1() { System.out.println("钻石会员对所有的服装都有:"+a13+"的折扣"); } } class Baijin111 extends Fuzhuang1 { double a23 = 0.8; void zhekou2() { System.out.println("白金会员对所有的服装都有:"+a23+"的折扣"); } } class Muying1 //建立一个父类表示会员对母婴类商品的了解 { final double pjshoujia = 156.8; double zhekou; int kucun =3428; } class Zhizun1a extends Muying1 { double a13 = 0.6; void zhekou(){ System.out.println("至尊会员对所有的母婴产品都有:"+a13+"的折扣"); } void kucun() { System.out.println("母婴产品平均每种的库存为:"+kucun); System.out.println("每种母婴产品的平均的销售价格为:"+pjshoujia); } } class Zuanshi1a extends Muying1 { double a14 = 0.75; void zhekou1() { System.out.println("钻石会员对所有的母婴产品都有:"+a14+"的折扣"); } } class Baijin1a extends Muying1 { double a24 = 0.8; void zhekou2() { System.out.println("白金会员对所有的母婴产品都有:"+a24+"的折扣"); } } class Shipin1 //建立一个父类表示会员对食品类商品的了解 { final double pjshoujia = 58.8; double zhekou; int kucun =3428; } class Zhizun1b extends Shipin1 { double a14 = 0.6; void zhekou() { System.out.println("至尊会员对所有的食品都有:"+a14+"的折扣"); } void kucun() { System.out.println("食品平均每种的库存为:"+kucun); System.out.println("每种食品的平均的销售价格为:"+pjshoujia); } } class Zuanshi1b extends Shipin1 { double a15 = 0.75; void zhekou1() { System.out.println("钻石会员对所有的食品都有:"+a15+"的折扣"); } } class Baijin1b extends Shipin1 { double a25 = 0.8; void zhekou2() { System.out.println("白金会员对所有的食品都有:"+a25+"的折扣"); } } abstract class Gouwu //建立一个抽象父类,表示买家可以查看购物信息 { String dingdan; int num; double zhichu; } class Dingdan extends Gouwu { void Lishi1() { double benjin = 78.8; double sum = benjin * 3; System.out.println("购买3本计算机类的图书共花费"+sum); //还可以加购买日期 } void Lishi2() { double benjin = 3666; double sum = benjin; System.out.println("购买电视机1台共花费"+sum); //还可以加购买日期 } void Lishi3() { double benjin = 300; double sum = benjin * 2; System.out.println("购买短袖2件共花费"+sum); //还可以加购买日期 } void Lishi4() { double benjin = 156.8; double sum = benjin ; System.out.println("购买尿不湿1包共花费"+sum); //还可以加购买日期 } void Lishi5() { double benjin = 58.8; double sum = benjin * 10; System.out.println("购买10包辣条共花费"+sum); //还可以加购买日期 } } class Tushua //建立一个父类表示老板对图书的打折及盈利情况 { final double pjbenjin = 38.8; final double pjshoujia = 78.8; double zhekou; double lirun; int kucun = 1324; } class Zhizuna extends Tushua { double a = 0.5; void zhekou() { System.out.println("至尊会员对所有的图书都有:"+a+"的折扣"); } void lirun() { double b = pjshoujia * a - pjbenjin; System.out.printf("至尊会员买书可产生的利润为:%1.2f",b); System.out.println(); } void kucun() { System.out.println("图书平均每种的库存为:"+kucun); System.out.println("每种图书的平均的本金价格为:"+pjbenjin); System.out.println("每种图书的平均的销售价格为:"+pjshoujia); } } class Zuanshia extends Tushua { double a1 = 0.65; void zhekou1() { System.out.println("钻石会员对所有的图书都有:"+a1+"的折扣"); } void lirun1() { double b1 = pjshoujia * a1 - pjbenjin; System.out.printf("钻石会员买书可产生的利润为:%1.2f",b1); System.out.println(); } } class Baijin1aa extends Tushua { double a2 = 0.8; void zhekou2() { System.out.println("白金会员对所有的图书都有:"+a2+"的折扣"); } void lirun2() { double b2 = pjshoujia * a2 - pjbenjin; System.out.printf("白金会员买书可产生的利润为:%1.2f",b2); } } class Dianqi1a ////建立一个父类表示老板对电器的打折及盈利情况 { final double pjbenjin = 1888; final double pjshoujia = 3666; double zhekou; double lirun; int kucun = 366; } class Zhizun1aa extends Dianqi1a { double a11 = 0.6; void zhekou() { System.out.println("至尊会员对所有的电器都有:"+a11+"的折扣"); } void lirun() { double b11 = pjshoujia * a11 - pjbenjin; System.out.printf("至尊会员买电器可产生的利润为:%1.2f",b11); System.out.println(); } void kucun() { System.out.println("电器平均每种的库存为:"+kucun); System.out.println("每种电器的平均的本金价格为:"+pjbenjin); System.out.println("每种电器的平均的销售价格为:"+pjshoujia); } } class Zuanshi1aa extends Dianqi1a { double a12 = 0.75; void zhekou1() { System.out.println("钻石会员对所有的电器都有:"+a12+"的折扣"); } void lirun1() { double b12 = pjshoujia * a12 - pjbenjin; System.out.printf("钻石会员买电器可产生的利润为:%1.2f",b12); System.out.println(); } } class Baijin11a extends Dianqi1a { double a22 = 0.8; void zhekou2() { System.out.println("白金会员对所有的电器都有:"+a22+"的折扣"); } void lirun2() { double b22 = pjshoujia * a22 - pjbenjin; System.out.printf("白金会员买电器可产生的利润为:%1.2f",b22); } } class Fuzhuang1a ////建立一个父类表示老板对服装的打折及盈利情况 { final double pjbenjin = 80; final double pjshoujia = 300; double zhekou; double lirun; int kucun =6666; } class Zhizun11a extends Fuzhuang1a { double a12 = 0.6; void zhekou(){ System.out.println("至尊会员对所有的服装都有:"+a12+"的折扣"); } void lirun() { double b12 = pjshoujia * a12 - pjbenjin; System.out.printf("至尊会员买服装可产生的利润为:%1.2f",b12); System.out.println(); } void kucun() { System.out.println("图服装平均每种的库存为:"+kucun); System.out.println("每种服装的平均的本金价格为:"+pjbenjin); System.out.println("每种服装的平均的销售价格为:"+pjshoujia); } } class Zuanshi11a extends Fuzhuang1a { double a13 = 0.75; void zhekou1() { System.out.println("钻石会员对所有的服装都有:"+a13+"的折扣"); } void lirun1() { double b13 = pjshoujia * a13 - pjbenjin; System.out.printf("钻石会员买服装可产生的利润为:%1.2f",b13); System.out.println(); } } class Baijin111a extends Fuzhuang1a { double a23 = 0.8; void zhekou2() { System.out.println("白金会员对所有的服装都有:"+a23+"的折扣"); } void lirun2() { double b23 = pjshoujia * a23 - pjbenjin; System.out.printf("白金会员买服装可产生的利润为:%1.2f",b23); } } class Muying1a ////建立一个父类表示老板对母婴的打折及盈利情况 { final double pjbenjin = 88.9; final double pjshoujia = 156.8; double zhekou; double lirun; int kucun =3428; } class Zhizun1a1 extends Muying1a { double a13 = 0.6; void zhekou(){ System.out.println("至尊会员对所有的母婴产品都有:"+a13+"的折扣"); } void lirun() { double b13 = pjshoujia * a13 - pjbenjin; System.out.printf("至尊会员买母婴产品可产生的利润为:%1.2f",b13); System.out.println(); } void kucun() { System.out.println("母婴产品平均每种的库存为:"+kucun); System.out.println("每种母婴产品的平均的本金价格为:"+pjbenjin); System.out.println("每种母婴产品的平均的销售价格为:"+pjshoujia); } } class Zuanshi1a1 extends Muying1a { double a14 = 0.75; void zhekou1() { System.out.println("钻石会员对所有的母婴产品都有:"+a14+"的折扣"); } void lirun1() { double b14 = pjshoujia * a14 - pjbenjin; System.out.printf("钻石会员买母婴产品可产生的利润为:%1.2f",b14); System.out.println(); } } class Baijin1a1 extends Muying1a { double a24 = 0.8; void zhekou2() { System.out.println("白金会员对所有的母婴产品都有:"+a24+"的折扣"); } void lirun2() { double b24 = pjshoujia * a24 - pjbenjin; System.out.printf("白金会员买母婴产品可产生的利润为:%1.2f",b24); } } class Shipin1a ////建立一个父类表示老板对食品的打折及盈利情况 { final double pjbenjin = 32.5; final double pjshoujia = 58.8; double zhekou; double lirun; int kucun =3428; } class Zhizun1b1 extends Shipin1a { double a14 = 0.6; void zhekou() { System.out.println("至尊会员对所有的食品都有:"+a14+"的折扣"); } void lirun() { double b14 = pjshoujia * a14 - pjbenjin; System.out.printf("至尊会员买食品可产生的利润为:%1.2f",b14); System.out.println(); } void kucun() { System.out.println("图食品平均每种的库存为:"+kucun); System.out.println("每种食品的平均的本金价格为:"+pjbenjin); System.out.println("每种食品的平均的销售价格为:"+pjshoujia); } } class Zuanshi1b1 extends Shipin1a { double a15 = 0.75; void zhekou1() { System.out.println("钻石会员对所有的食品都有:"+a15+"的折扣"); } void lirun1() { double b15 = pjshoujia * a15 - pjbenjin; System.out.printf("钻石会员买食品可产生的利润为:%1.2f",b15); System.out.println(); } } class Baijin1b1 extends Shipin1a { double a25 = 0.8; void zhekou2() { System.out.println("白金会员对所有的食品都有:"+a25+"的折扣"); } void lirun2() { double b25 = pjshoujia * a25 - pjbenjin; System.out.printf("白金会员买食品可产生的利润为:%1.2f",b25); } }
输出结果分了多种情况,具体不在这配图了。
时间: 2024-10-14 10:11:58