<前>
import java.util.Scanner;
public class 管理员,{
String 名称;
String oldpsw;
String newpsw;
String repsw;
Scanner 输入=new 扫描仪(系统);
public void 改变(){
System.out.println(“请输入用户名:“);
String inputname=input.next ();
System.out.println(“请输入密码:“);
String inputpsw=input.next ();
如果(inputname.equals(名字),和inputpsw.equals (oldpsw)) {
System.out.println(“请输入新密码“);
newpsw=input.next ();
System.out.println(“请再次输入密码“);
repsw=input.next ();
如果(newpsw.equals (repsw)) {
System.out.println(“密码修改成功!“);
oldpsw=newpsw;
}
而(! (newpsw.equals (repsw))) {
System.out.println(“密码输入错误,请重新输入!“);
System.out.println(“请输入您的新密码:“);
newpsw=input.next ();
System.out.println(“请再次输入新密码“);
repsw=input.next ();
}
System.out.println(“密码修改成功!“);
}
其他{
System.out.println(“您的账号密码输入有误,请重新输入!“);
}
}
public void 显示(){
System.out.println(“名称“+“\ \ t价格“);
System.out.println(“可乐330 ml" +“\ t3元“);
System.out.println(“雪碧330 ml" +“\ t3元“);
System.out.println(“电饭锅”+“\ t \ t300元“);
}
public void 支付(){
String name =,““
double price =, 0.0;
int goodsNo =, 0;
int amount =, 0;
double discount =, 0.8;
double total =, 0.0;
double payment =, 0.0;
System.out.println (“* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *“);
System.out.println(“请选择购买的商品编号:“);
System.out.println(“1。可乐,,,,,,,,2。雪碧,,,,,,,,3。电饭锅“);
System.out.println (“* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *“);
String answer =,“y";
而(“y" .equals(回答)){
System.out.print (“\ n请输入商品编号:“);
时间=goodsNo input.nextInt ();
开关(商品编号){
case 1:
时间=name “可乐“;
时间=price 3;
打破;
case 2:
时间=name “雪碧“;
时间=price 3;
打破;
case 3:
时间=name “电饭锅“;
时间=price 300;
打破;
}
System.out.print(“请输入购买数量:“);
时间=amount input.nextInt ();
System.out.println(名字+,“¥”,+,price +“\ t数量,,,+,金额
+,“\ t合计,¥“,+,价格*数量);
+=total 价格*数量;
System.out.print(“是否继续(y/n)“);
时间=answer input.next ();
}
System.out.println (“\ n折扣:“,+,折扣);
System.out.println(“应付金额:“,+总*折扣);
System.out.print(“实付金额:“);
时间=payment input.nextDouble ();
而(payment 作用;总* discount & lt;, 0) {
System.out.print(“您输入的金额小于应付金额,请重新输入:“);
时间=payment input.nextDouble ();
}
System.out.println(“找钱:“,+,(payment 安康;总*折扣));
}
public void 星云(){
int random =, (int), (math . random (), *, 10);
System.out.println(“我行我素购物管理系统,祝辞,幸运抽奖\ n");
System.out.print(“请输入4位会员号:,“);
int custNo =, input.nextInt ();
int baiwei =, custNo /, 100, %, 10;
if (baiwei ==,随机的),{
System.out.println (custNo +,“是幸运客户,获精美Mp3一个!”);
},{else
System.out.println (custNo +,,,,谢谢您的支持!“);
}
}
public void  huangou () {
System.out.print(“请输入消费金额:“);
double money =, input.nextDouble ();
double extra =, 0,,,,
int choice =0;祝福;
如果(money>=50) {
System.out.println(“是否参加优惠换购活动:“);
System.out.println(“1:满50元,加2元换购百事可乐饮料1瓶“);
System.out.println(“2:满100元,加3元换购500毫升可乐一瓶“);
System.out.println(“3:满100元,加10元换购5公斤面粉“);
System.out.println(“4:满200元,加10元可换购1个苏泊尔炒菜锅“);
System.out.println(“5:满200元,加20元可换购欧莱雅爽肤水一瓶“);
System.out.println(“0:不换购“);
System.out.print(“请选择:“);
如果(input.hasNextInt ()==true) {
时间=choice input.nextInt ();
开关(选择){
case 1:
如果(money>=50) {
extra =, 2;
}
打破;
case 2:
如果(money>=100) {
时间=extra 3;
}
打破;
case 3:
如果(money>=100) {
时间=extra 10;
}
打破;
case 4:
如果(money>=200) {
时间=extra 10;
}
打破;
case 5:
如果(money> 200) {
时间=extra 20;
}
打破;
默认值:
打破;
}
其他}{
System.out.println(“请输入正确的数字!“);
}
}
double total =, money +,额外的;
System.out.println(“本次消费总金额:“+,);
如果(==choice 1) {
System.out.println(“成功换购:“,+,“百事可乐饮料1瓶!”);
}else 如果(choice ==2,) {
System.out.println(“成功换购:“,+,“500毫升可乐一瓶!”);
}else 如果(==choice 3) {
System.out.println(“成功换购:“,+,“5公斤面粉!”);
}else 如果(==choice 4) {
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null