package?Test;
站在用戶的角度思考問題,與客戶深入溝通,找到廈門網(wǎng)站設(shè)計(jì)與廈門網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶體驗(yàn)好的作品,建站類型包括:成都網(wǎng)站設(shè)計(jì)、網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、國際域名空間、虛擬空間、企業(yè)郵箱。業(yè)務(wù)覆蓋廈門地區(qū)。
import?java.util.LinkedHashMap;
import?java.util.Map;
import?java.util.Map.Entry;
import?java.util.Scanner;
public?class?Test?{
public?static?void?main(String[]?args)?{
init();//初始化
MapString,String?map?=?new?LinkedHashMap();
while(true){
Scanner?in=?new?Scanner(System.in);
map?=?buy(in,map);//選擇
System.out.println();
System.out.println("還要繼續(xù)購物嗎?(Y/N)");
String?jx?=?in.nextLine();
if(jx.equals("N")){
break;
}
}
print(map);
}
public?static?void?print(MapString,?String?m){
System.out.println("\n\n\n******************");
System.out.println("???????購物車清單");
Integer?hj?=?0;
for?(EntryString,?String?entry?:?m.entrySet())?{
String?key?=?entry.getKey();
String?value?=?entry.getValue();
if(key.equals("1")){
hj?+=?Integer.parseInt(value)*3;
System.out.println("哇哈哈純凈水:?"+value+"件,合計(jì):¥"+Integer.parseInt(value)*3);
}else?if(key.equals("2")){
hj?+=?Integer.parseInt(value)*5;
System.out.println("康師傅方便面:?"+value+"件,合計(jì):¥"+Integer.parseInt(value)*5);
}else?if(key.equals("3")){
hj?+=?Integer.parseInt(value)*4;
System.out.println("可口可樂:?"+value+"件,合計(jì):¥"+Integer.parseInt(value)*4);
}
}
System.out.println("合計(jì)金額:¥"+hj);
}
public?static?void?init(){
System.out.println("******************");
System.out.println("\t商品列表\n");
System.out.println("??????????????商品名稱????????????????價(jià)格");
System.out.println("1.???哇哈哈純凈水????????¥3");
System.out.println("2.???康師傅方便面????????¥5");
System.out.println("3.???可口可樂????????????????¥4");
System.out.println("******************");
}
public?static?MapString,String?buy(Scanner?scan,MapString,String?m){
System.out.print("請輸入編號:");
String?bh?=?scan.nextLine();
System.out.print("請輸入購買數(shù)量:");
String?num?=?scan.nextLine();
if(m.size()0??m.keySet().contains(bh)){
m.put(bh,(Integer.parseInt(bh)+Integer.parseInt(num))+"");
}else{
m.put(bh,?num);
}
return?m;
}
}
2、public class Test11 {
public static void main(String[] args) {
System.out.println("滯貿(mào)旅客的人數(shù)" + (1189 - 108*10) );
}
}
3、public class Test11 {
public static void main(String[] args) {
try {
Scanner scanner = new Scanner(System.in);
System.out.print("輸入購買雞蛋(斤):");
int number = scanner.nextInt();
if(number10){
throw new RuntimeException("不允許購買這么多!");
}
else {
System.out.println("用戶應(yīng)支付金額"+number*3.98);
}
}
catch (Exception e){
System.out.println(e.getMessage());
}
}
}
算是最簡單的吧
package cn.job01;
import java.util.Scanner;
public class Lx07 {
public static void choice() {
System.out.println("登陸菜單 ");
System.out.println("1登陸系統(tǒng)");
System.out.println("2退出");
}
static void choice1() {
System.out.println("購物管理系統(tǒng)客戶信息");
System.out.println("1顯示所有客戶信息");
System.out.println("2添加客戶信息");
System.out.println("3修改客戶信息");
System.out.println("4查詢客戶信息");
}
static void choice2() {
System.out.println("購物管理系統(tǒng)真情回饋");
System.out.println("1幸運(yùn)大放送");
System.out.println("2幸運(yùn)抽獎(jiǎng)");
System.out.println("3生日問候");
}
public static void main(String[] args) {
choice();
Scanner input = new Scanner(System.in);
System.out.println("請輸入1or2");
int num = input.nextInt();
switch (num) {
case 1:
System.out.println("主菜單");
System.out.println("1客戶信息管理");
System.out.println("2購物結(jié)算");
System.out.println("3真情回饋");
System.out.println("4注銷");
break;
}
System.out.println("選擇輸入數(shù)字");
int num1 = input.nextInt();
switch (num1) {
case 1:
choice1();
break;
case 2:
System.out.println("購物結(jié)算");
break;
case 3:
choice2();
break;
case 4:
choice();
break;
}
}
}