您好,登錄后才能下訂單哦!
import java.util.Scanner; public class 管理員 { String name; String oldpsw; String newpsw; String repsw; Scanner input=new Scanner(System.in); public void Change(){ System.out.println("請(qǐng)輸入用戶名:"); String inputname=input.next(); System.out.println("請(qǐng)輸入密碼:"); String inputpsw=input.next(); if(inputname.equals(name)&&inputpsw.equals(oldpsw)){ System.out.println("請(qǐng)輸入新密碼"); newpsw=input.next(); System.out.println("請(qǐng)?jiān)俅屋斎朊艽a"); repsw=input.next(); if(newpsw.equals(repsw)){ System.out.println("密碼修改成功!"); oldpsw=newpsw; } while(!(newpsw.equals(repsw))){ System.out.println("密碼輸入錯(cuò)誤,請(qǐng)重新輸入!"); System.out.println("請(qǐng)輸入您的新密碼:"); newpsw=input.next(); System.out.println("請(qǐng)?jiān)俅屋斎胄旅艽a"); repsw=input.next(); } System.out.println("密碼修改成功!"); } else{ System.out.println("您的賬號(hào)密碼輸入有誤,請(qǐng)重新輸入!"); } } public void show(){ System.out.println("名稱"+"\t\t價(jià)格"); System.out.println("可樂(lè)330ml"+"\t3元"); System.out.println("雪碧330ml"+"\t3元"); System.out.println("電飯鍋"+"\t\t300元"); } public void pay(){ 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("請(qǐng)選擇購(gòu)買的商品編號(hào):"); System.out.println("1.可樂(lè) 2.雪碧 3.電飯鍋"); System.out.println("*******************************************"); String answer = "y"; while("y".equals(answer)){ System.out.print("\n請(qǐng)輸入商品編號(hào):"); goodsNo = input.nextInt(); switch(goodsNo){ case 1: name = "可樂(lè)"; price = 3; break; case 2: name = "雪碧"; price = 3; break; case 3: name = "電飯鍋"; price = 300; break; } System.out.print("請(qǐng)輸入購(gòu)買數(shù)量:"); amount = input.nextInt(); System.out.println(name+ "¥" + price +"\t數(shù)量 " + amount + "\t合計(jì) ¥" + price*amount); total += price*amount; System.out.print("是否繼續(xù)(y/n)"); answer = input.next(); } System.out.println("\n折扣:" + discount); System.out.println("應(yīng)付金額:" +total*discount); System.out.print("實(shí)付金額:"); payment = input.nextDouble(); while(payment - total*discount < 0){ System.out.print("您輸入的金額小于應(yīng)付金額,請(qǐng)重新輸入:"); payment = input.nextDouble(); } System.out.println("找錢:" + (payment - total*discount)); } public void xingyun(){ int random = (int) (Math.random() * 10); System.out.println("我行我素購(gòu)物管理系統(tǒng) > 幸運(yùn)抽獎(jiǎng)\n"); System.out.print("請(qǐng)輸入4位會(huì)員號(hào): "); int custNo = input.nextInt(); int baiwei = custNo / 100 % 10; if (baiwei == random) { System.out.println(custNo + "是幸運(yùn)客戶,獲精美Mp3一個(gè)。"); } else { System.out.println(custNo + " 謝謝您的支持!"); } } public void huangou(){ System.out.print("請(qǐng)輸入消費(fèi)金額:"); double money = input.nextDouble(); double extra = 0; int choice = 0; if(money>=50){ System.out.println("是否參加優(yōu)惠換購(gòu)活動(dòng):"); System.out.println("1:滿50元,加2元換購(gòu)百事可樂(lè)飲料1瓶"); System.out.println("2:滿100元,加3元換購(gòu)500ml可樂(lè)一瓶"); System.out.println("3:滿100元,加10元換購(gòu)5公斤面粉"); System.out.println("4:滿200元,加10元可換購(gòu)1個(gè)蘇泊爾炒菜鍋"); System.out.println("5:滿200元,加20元可換購(gòu)歐萊雅爽膚水一瓶"); System.out.println("0:不換購(gòu)"); System.out.print("請(qǐng)選擇:"); if(input.hasNextInt()==true){ choice = input.nextInt(); switch(choice){ case 1: if(money>=50){ extra = 2; } break; case 2: if(money>=100){ extra = 3; } break; case 3: if(money>=100){ extra = 10; } break; case 4: if(money>=200){ extra = 10; } break; case 5: if(money>200){ extra = 20; } break; default: break; } }else{ System.out.println("請(qǐng)輸入正確的數(shù)字!"); } } double total = money + extra; System.out.println("本次消費(fèi)總金額:"+ total); if(choice == 1){ System.out.println("成功換購(gòu):" + "百事可樂(lè)飲料1瓶。"); }else if(choice ==2 ){ System.out.println("成功換購(gòu):" + "500ml可樂(lè)一瓶。"); }else if(choice == 3){ System.out.println("成功換購(gòu):" + "5公斤面粉。"); }else if(choice == 4){ System.out.println("成功換購(gòu):" + "1個(gè)蘇泊爾炒菜鍋。"); }else if(choice == 5){ System.out.println("成功換購(gòu):" + "歐萊雅爽膚水一瓶。"); }else { System.out.println("無(wú)換購(gòu)項(xiàng)目!"); } } }
import java.util.Scanner; public class 主體 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub 管理員 XG=new 管理員(); Scanner input=new Scanner(System.in); String account="TOM"; String pwd="123"; System.out.println("請(qǐng)選擇!"); System.out.println("1.登錄我行我素管理系統(tǒng)"); System.out.println("2.修改管理員密碼"); int KS=input.nextInt(); switch(KS){ case 1:System.out.println("請(qǐng)輸入您的賬號(hào)"); String A=input.next(); System.out.println("請(qǐng)輸入您的密碼"); String B=input.next(); if(account.equals(A)&&pwd.equals(B)){ System.out.println("登錄成功!"); System.out.println("歡迎進(jìn)入我行我素~~"); System.out.println("***************************"); System.out.println("請(qǐng)選擇您的選項(xiàng)"); System.out.println("****************************"); System.out.println("1.查詢商品價(jià)格"); System.out.println("2.購(gòu)物結(jié)算計(jì)算"); System.out.println("3.幸運(yùn)抽獎(jiǎng)"); System.out.println("4.商品換購(gòu)"); int F=input.nextInt(); switch(F){ case 1: XG.show(); break; case 2: XG.pay(); break; case 3: XG.xingyun(); break; case 4: XG.huangou(); } } else{ System.out.println("賬號(hào)密碼錯(cuò)誤,請(qǐng)重新輸入!"); } break; case 2: XG.name="TOM"; XG.oldpsw="123"; XG.Change(); break; } } }
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。