编程知识 cdmana.com

Initialization of the third dish in the total amount column output by the food alliance system

import java.util.Scanner;

public class CHLM {

public static void main(String[] args) {    // Array     String[] names =new String[4];    String[] dishMegs = new     String[4];    int[] times= new int[4];    String[] addresses=new String[4];    int[] states =new int[4];    double[] sumPrices =new double[4];    // Initialization menu     String[] dishNames={
   
   
   
   " Braised Hairtail in Brown Sauce "," Yu-Shiang Shredded Pork "," Seasonal fresh vegetables "};    double[] prices=new double[] {
   
   
   
   38.0,20.0,10.0};    int[] prasieNums=new int[3];    // Initialize order     names[0]=" Zhang Qing ";    dishMegs[0]=" Braised Hairtail in Brown Sauce 2 Share ";    times[0]=12;    addresses[0]=" Tiancheng Road 207 Number ";    sumPrices[0]=70.6;    states[0]=1;    // Personal information     names[1]=" Li Jianing ";    dishMegs[1]=" Yu-Shiang Shredded Pork 2 branch ";    times[1]=20;    addresses[1]=" No. 4 apartment building of Linyi Vocational College of science and Technology 422 dormitory ";    sumPrices[1]=45.0;    states[1]=0;    // Get the keyboard     Scanner input=new Scanner(System.in);    int num=-1;    boolean isExit=false;    // Order circulation system     do{        System.out.println("*************************");        System.out.println("1、 I want to order ");        System.out.println("2、 Check out the food bag ");        System.out.println("3、 Sign the order ");        System.out.println("4、 Delete order ");        System.out.println("5、 I want to like ");        System.out.println("6、 Exit the system ");        System.out.println("*************************");        System.out.println(" Please select :");        int choose=input.nextInt();        // loop         switch(choose){        case 1:            System.out.println("*** I want to order ***");            Boolean isAdd=false;            for(int j=0;j<names.length;j++){                if(names[j]==null){                    isAdd=true;                    System.out.print(" Please enter the name of the orderer :");                    String name=input.next();                    System.out.println(" Serial number "+"\t"+" Dish name "+"\t"+" The unit price "+"\t"+" Number of likes ");                    for(int i=0;i<dishNames.length;i++){                        String price =prices[i]+" element ";                        String priaiseNum=(prasieNums[i]>0?prasieNums[i]+" Fabulous ":"0");                                System.out.println((i+1)+"\t"+dishMegs[i]+"\t"+price+"\t"+priaiseNum);                    }                    // User ordering                                 System.out.print(" Please select the item number you want :");                                int chooseDish=input.nextInt();                                System.out.print(" Please select the number of copies you need :");                                int number=input.nextInt();                                String dishMeg=dishNames[chooseDish-1]+""+number+" Share ";                                double sumPrice=prices[chooseDish-1]*number;                                                                double deliCharge=(sumPrice>=50)?0:5;;                                                                System.out.print(" Please enter the delivery time ( What's the delivery time 10 Point to the 20 The meal is delivered at one o'clock ):");                                int time=input.nextInt();                                while(time<10||time>20){                                    System.out.print(" Your input is wrong , Please enter 10~20 The whole number between !");                                    time=input.nextInt();                                }                                System.out.print(" Please enter the delivery address :");                                String address=input.next();                                                                System.out.println(" The meal was ordered successfully ");                                System.out.println(" What's your order :"+dishMeg);                                System.out.println(" What's the delivery time :"+time+" spot ");                                System.out.println(" meals :"+sumPrice+" element , Meal delivery fee "+deliCharge+" element , A total of "+(sumPrice+deliCharge)+" element .");                                                                names[j]=name;                                dishMegs[j]=dishMeg;                                times[j]=time;                                addresses[j]=address;                                sumPrices[j]=sumPrice+deliCharge;                                break;                    }                }                if(!isAdd){                    System.out.println(" I'm sorry , Your bag is full !");                }                break;        case 2:            System.out.println("*** Check out the food bag **");            System.out.println(" Serial number \t The orderer \t Food information \t Delivery time \t\t Delivery address \t\t Total sum \t\t The order status ");            for(int i=0;i<names.length;i++){                if(names[i]!=null){                    String state=(states[i]==0)?" Booked ":" Completed ";                String date=times[i]+" spot ";                String sumPrice=sumPrices[i]+" element ";                System.out.println((i+1)+"\t"+names[i]+"\t"+dishMegs[i]+"\t"+date+"\t"+addresses[i]+"\t"+states+"\t"+sumPrices+"\t"+state);                }            }            break;        case 3:            System.out.println("*** Sign the order ***");            boolean isSignFind=false;            System.out.print(" Please select the order serial number to sign :");            int signOraderld=input.nextInt();            for(int i=0;i<names.length;i++){                if(names[i]!=null&&states[i]==0&&signOraderld==i+1){                    states[i]=1;                    System.out.print(" After the order is signed successfully !");                    isSignFind=true;                }else if(names[i]!=null&&states[i]==1&&signOraderld==i+1){                    System.out.print(" The order you selected has been signed in , Can't sign again !");                    isSignFind=true;                    }                }            if(!isSignFind){                System.out.println(" The order you selected does not exist !");            }            break;        case 4:            System.out.println("*** Delete order ***");            boolean isDelFind=false;            System.out.print(" Please enter the order number to delete :");            int delld=input.nextInt();            for(int i=0;i<names.length;i++){                if(names[i]!=null&&states[i]==1&&delld==i+1){                    isDelFind=true;                    for(int j=delld-1;j<names.length-1;j++){                        names[j]=names[j+1];                        dishMegs[j]=dishMegs[j+1];                        times[j]=times[j+1];                        addresses[j]=addresses[j+1];                        states[j]=states[j+1];                        sumPrices[j]=sumPrices[j+1];                    }                    int endlindex=names.length-1;                    names[endlindex]=null;                    dishMegs[endlindex]=null;                    times[endlindex]=0;                    addresses[endlindex]=null;                    states[endlindex]=0;                    sumPrices[endlindex]=0;                    System.out.println(" Order deleted successfully !");                    break;                }else if(names[i]!=null&&states[i]==0){                    System.out.println(" The order you selected is not signed , Can't delete !");                    isDelFind=true;                    break;                }            }            if(!isDelFind){                System.out.println(" The order you want to delete does not exist !");            }            break;        case 5:            System.out.println("*** I want to like ***");            System.out.println(" Serial number "+"\t"+" Dish name "+"\t"+" The unit price ");            for(int i=0;i<dishNames.length;i++){                String price=prices[i]+" element ";                String priaiseNum=(prasieNums[i]>0?prasieNums[i]+" Fabulous ":"0");                System.out.println((i+1)+"\t"+dishMegs[i]+"\t"+price+"\t"+priaiseNum);            }            System.out.print(" Please select the serial number of the dish you like :");            int priaiseNum=input.nextInt();            prasieNums[priaiseNum-1]++;            System.out.println(" I like it !");            break;        default:            isExit=true;            break;    }        if(!isExit){            System.out.print(" Input 0 return :");            num=input.nextInt();        }else{            break;}        }while(num==0);}

}

版权声明
本文为[CSDN Q & A]所创,转载请带上原文链接,感谢
https://cdmana.com/2021/12/20211207165416956m.html

Scroll to Top