2019年1月8日;吃货联盟订餐系统
吃货联盟订餐系统
java文件分享地址:
链接:https://pan.baidu.com/s/1e5QWeH1ui55O4hk3lEiS2Q
提取码:4gl7
复制这段内容后打开百度网盘手机App,操作更方便哦
编写代码为:
package com.dingcan;
/**
* 吃货联盟订餐系统
* @author 刘铭辉
* 2019-1-8
*/
import java.util.Scanner;
public class DingCan2 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String[] menu = new String[] {"红烧带鱼","鱼香肉丝","时令鲜蔬"};
int[] zan = new int[3];
String[] name = new String[4];
String[] chose = new String[4];
String[] adr = new String[4];
int[] copies = new int[4];
double[] pay = new double[4];
int[] time = new int[4];
int[] zhuangTai = new int[4];
double[] payEnd=new double[4];
boolean flag = false;
double pay1 = 0.0;
double pay2 = 0.0;
double pay3 = 0.0;
double tip =6.0;
int i=0;
System.out.println("欢迎使用吃货联盟订餐系统");
while(true) {
System.out.println("**********************************");
System.out.println("1、我要订餐");
System.out.println("2、查看餐袋");
System.out.println("3、签收订单");
System.out.println("4、删除订单");
System.out.println("5、我要点赞");
System.out.println("6、退出系统");
System.out.println("**********************************");
System.out.println("请选择:");
int key = input.nextInt();
if(key==1) {
for(;true;) {
System.out.println("***我要订餐***");
System.out.println("序号\t菜名\t单价");
System.out.println("1\t红烧带鱼\t38.0元\t点赞数:"+zan[0]);
System.out.println("2\t鱼香肉丝\t20.0元\t点赞数:"+zan[1]);
System.out.println("3\t时令鲜蔬\t10.0元\t点赞数:"+zan[2]);
System.out.println("请选择您要点的菜品编号:");
int food = input.nextInt();
if(food>menu.length) {
System.out.println("您输入有误,请重新选择!");
continue;
}
System.out.println("请选择您需要的份数:(3份及以上免配送费)");
copies[i] = input.nextInt();
System.out.println("请输入订餐人姓名:");
name[i] = input.next();
System.out.println("请输入送餐时间(送餐时间是10点至20点间整点送餐):");
do{
time[i] = input.nextInt();
if(time[i]>=10&&time[i]<=20) {
break;
}else {
System.out.println("您的输入有误,请输入10~20间的整数:");
}
}while(true);
System.out.println("请输入送餐地址:");
adr[i] = input.next();
System.out.println("订单成功!");
zhuangTai[i]=0;
if(food==1) {
System.out.println("您订的是:红烧带鱼"+copies[i]+"份");
pay1 = 38.0;
chose[i]="红烧带鱼";
}
if(food==2) {
System.out.println("您订的是:鱼香肉丝"+copies[i]+"份");
pay2 = 20.0;
chose[i]="鱼香肉丝";
}
if(food==3) {
System.out.println("您订的是:时令鲜蔬"+copies[i]+"份");
pay3 = 10.0;
chose[i]="时令鲜蔬";
}
pay[i]=pay1*copies[i]+pay2*copies[i]+pay3*copies[i];
if(copies[i]>=3) {
payEnd[i]=pay[i];
System.out.println("送餐时间为:"+time[i]+"点");
System.out.print("餐费:"+pay[i]+"元,");
System.out.println("共计:"+payEnd[i]+"元");
}else {
payEnd[i]=pay[i]+tip;
System.out.println("送餐时间为:"+time[i]+"点");
System.out.print("餐费:"+pay[i]+"元,");
System.out.print("送餐费"+tip+",");
System.out.println("共计:"+payEnd[i]+"元");
}
i++;
do {
System.out.println("输入0返回:");
int end = input.nextInt();
if(end==0) {
flag =true;
break;
}else {
System.out.println("输入有误!确认订单后可返回主页面查询订单!");
}
}while(true);
if(flag) {
break;
}
}
}
if(key==2) {
System.out.println("***查看餐袋***");
if(copies[0]==0) {
System.out.println("您没有订单!请返回下单!");
}else {
System.out.println("序号\t订餐人\t餐品信息\t\t送餐日期\t送餐地址\t\t总金额\t订单状态");
for(int j=0;j<name.length;j++){
if(copies[j]==0) {
break;
}
String zhuangtai=(zhuangTai[j]==0)?"已预定":"已完成";
System.out.println((j+1)+"\t"+name[j]+"\t"+chose[j]+copies[j]+"份"+"\t"+time[j]+"\t"+adr[j]+"\t\t"+payEnd[j]+"元\t"+zhuangtai);
}
}
do {
System.out.println("输入0返回:");
int end = input.nextInt();
if(end==0) {
break;
}else {
System.out.println("输入有误!确认订单后可返回主页面查询订单!");
}
}while(true);
}
if(key==3) {
System.out.println("***签收定单***");
if(copies[0]==0) {
System.out.println("您没有可签收订单!");
}else {
System.out.println("序号\t订餐人\t餐品信息\t\t送餐日期\t送餐地址\t\t总金额\t订单状态");
for(int j=0;j<name.length;j++){
if(copies[j]==0) {
break;
}
String zhuangtai=(zhuangTai[j]==0)?"已预定":"已完成";
System.out.println((j+1)+"\t"+name[j]+"\t"+chose[j]+copies[j]+"份"+"\t"+time[j]+"\t"+adr[j]+"\t\t"+payEnd[j]+"元\t"+zhuangtai);
}
System.out.print("请选择要签收的订单序号:");
int qianShou = input.nextInt();
if(qianShou<=0||qianShou>name.length||copies[qianShou-1]==0) {
System.out.println("您要删除的订单不存在!");
}else {
zhuangTai[qianShou-1]=1;
System.out.println("订单签收成功!");
}
}
do {
System.out.println("输入0返回:");
int end = input.nextInt();
if(end==0) {
break;
}else {
System.out.println("输入有误!确认订单后可返回主页面查询订单!");
}
}while(true);
}
if(key==4) {
System.out.println("***删除订单***");
if(copies[0]==0) {
System.out.println("您没有可删除订单!");
}else {
System.out.println("序号\t订餐人\t餐品信息\t\t送餐日期\t送餐地址\t\t总金额\t订单状态");
for(int j=0;j<name.length;j++){
if(copies[j]==0) {
break;
}
String zhuangtai=(zhuangTai[j]==0)?"已预定":"已完成";
System.out.println((j+1)+"\t"+name[j]+"\t"+chose[j]+copies[j]+"份"+"\t"+time[j]+"\t"+adr[j]+"\t\t"+payEnd[j]+"元\t"+zhuangtai);
}
System.out.print("请输入要删除的订单序号:");
int dele = input.nextInt();
if(dele<=0||dele>name.length||copies[dele-1]==0) {
System.out.println("您要删除的订单不存在!");
}
if(zhuangTai[dele-1]==0) {
System.out.println("您选择的订单未签收,不能删除!");
}else {
for(int a=dele-1;a<name.length-1;a++){
name[a]=name[a+1];
chose[a]=chose[a+1];
copies[a]=copies[a+1];
time[a]=time[a+1];
adr[a]=adr[a+1];
payEnd[a]=payEnd[a+1];
zhuangTai[a]=zhuangTai[a+1];
copies[copies.length-1]=0;
}
System.out.println("删除订单成功!");
}
}
do {
System.out.println("输入0返回:");
int end = input.nextInt();
if(end==0) {
break;
}else {
System.out.println("输入有误!确认订单后可返回主页面查询订单!");
}
}while(true);
}
if(key==5) {
System.out.println("***我要点赞***");
System.out.println("序号\t菜名\t单价");
System.out.println("1\t红烧带鱼\t38.0元\t点赞数:"+zan[0]);
System.out.println("2\t鱼香肉丝\t20.0元\t点赞数:"+zan[1]);
System.out.println("3\t时令鲜蔬\t10.0元\t点赞数:"+zan[2]);
System.out.print("请选择您要点赞的菜品编号:");
while(true) {
int good =input.nextInt();
switch(good) {
case 1:
zan[0]++;
System.out.println("点赞成功!");
break;
case 2:
zan[1]++;
System.out.println("点赞成功!");
break;
case 3:
zan[2]++;
System.out.println("点赞成功!");
break;
default:
System.out.println("您点赞有误,请重新输入!");
continue;
}
break;
}
do {
System.out.println("输入0返回:");
int end = input.nextInt();
if(end==0) {
break;
}else {
System.out.println("输入有误!确认订单后可返回主页面查询订单!");
}
}while(true);
}
if(key==6) {
System.out.println("谢谢使用,欢迎下次光临!");
break;
}
if(key>6||key<=0) {
System.out.println("您输入有误,请选择系统菜单编号重新输入!");
}
}
}
}
教学编码为:
java分享文件地址为:
链接:https://pan.baidu.com/s/1gqFi_qepWowcbIgCNdGI6w
提取码:lqt2
复制这段内容后打开百度网盘手机App,操作更方便哦
package com.dingcan;
import java.util.Scanner;
/**
* 吃货联盟订餐系统
*
* @author Mr.Zhou 2019-1-8
*/
public class EatSystem {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("欢迎使用“吃货联盟订餐系统”");
String choose = "";//菜单选择的变量
//初始化数据
int length = 5;
String[] names = new String[length];//订餐人
String[] descs = new String[length];//订单餐品信息
int[] dates =new int[length];//送餐日期
String[] addresses = new String[length];//送餐地址
double[] moneys = new double[length];//总价
boolean[] status = new boolean[length];//订餐状态:true:完成;false未完成
int[] nums = new int[length];//订餐数量
double[] prices = new double[10];//单价
String[] foods = new String[10];//菜品信息
int[] zan = new int[10];//点赞数量
zan[0] = 12;zan[2] = 5;zan[4]=25;
foods[0] = "黄焖鸡";foods[1] = "东坡肉";foods[2] = "蛋炒饭";foods[3] = "北京烤鸭";foods[4] = "大肘子";
prices[0] = 16.0;prices[1] = 15.5;prices[2] = 8.0;prices[3] = 49.9;prices[4] = 18.8;
names[0] = "陈明";
descs[0] = "黄焖鸡";
nums[0] = 2;
moneys[0] = 32.0;
dates[0] = 7;
addresses[0] = "北大青鸟";
status[0] = true;
names[1] = "刘铭辉";
descs[1] = "东坡肉";
nums[1] = 3;
moneys[1] = 46.5;
dates[1] = 8;
addresses[1] = "机房8";
status[1] = false;
do {
System.out.println("******************************");
System.out.println("1、我要订餐 2、查看餐袋 3、签收订单 4、删除订单 5、我要点赞 6、退出系统");
System.out.println("请选择:");
choose = sc.next();
switch (choose) {
case "1":
System.out.println("****我要订餐****");
int index = -1;//定义要添加的位置下标
for(int i = 0 ;i<length;i++) {
if(names[i]==null) {
index = i;
break;
}
}
if(index<0) {
System.out.println("当前餐袋已满!!!");
}else {
System.out.println("请输入订餐人姓名:");
names[index] = sc.next();
System.out.println("序号\t菜名\t单价\t点赞数量");
int max = foods.length;
for(int i = 0;i<foods.length;i++) {
if(foods[i]==null) {
max = i;
break;
}
System.out.println((i+1)+"\t"+foods[i]+"\t"+prices[i]+"元\t"+zan[i]+"次");
}
System.out.println("请选择您要点的菜品编号:");
int id = 0;
do {
id = sc.nextInt();
if(id<1||id>max) {
System.out.println("不存在此编号菜品,请重新输入:");
}
} while (id<1||id>max);
descs[index] = foods[id-1];
System.out.println("请选择您需要的份数:");
int num = sc.nextInt();
nums[index] = num;
System.out.println("请输入送餐时间(送餐时间是10点至20点间整点送餐)");
int date = 0;
do {
date = sc.nextInt();
if(date<10||date>20) {
System.out.println("您的输入有误,请输入10~20间的整数!:");
}
} while (date<10||date>20);
dates[index] = date;
System.out.println("请输入送餐地址:");
addresses[index] = sc.next();
double money = prices[id-1]*num;
System.out.println("订餐成功:");
System.out.println("您订的是:"+foods[id-1]+" "+num+"份");
System.out.println("送餐时间:"+date+"点");
double song = 0.0;
if(money<20) {
song = 3.0;
}
moneys[index] = money+song;
System.out.println("餐费:"+money+"。送餐费:"+song+"元,总计:"+(money+song)+"元");
}
break;
case "2":
System.out.println("****查看餐袋****");
System.out.println("序号\t订餐人\t餐品信息\t\t送餐日期\t\t送餐地址\t\t总金额\t订单状态");
for(int i = 0;i<length;i++) {
if(names[i]==null) {
break;
}
String canpin = descs[i]+" "+nums[i]+"份";
String zhuangtai = status[i]?"已完成":"已预订";
System.out.println((i+1)+"\t"+names[i]+"\t"+canpin+"\t"+dates[i]+"点\t\t"+addresses[i]+"\t\t"+moneys[i]+"元\t"+zhuangtai);
}
break;
case "3":
System.out.println("****签收订单****");
System.out.println("请输入要签收的订单编号:");
boolean isTrue = false;
int id = -1;
do {
id = sc.nextInt();
if(id<1||id>descs.length) {
isTrue = true;
}else {
if(descs[id-1]==null) {
isTrue = true;
}else {
isTrue = false;
}
}
if(isTrue) {
System.out.println("不存在此编号的订单信息,请重新输入:");
}
} while (isTrue);
status[id-1] = true;
System.out.println("签收完成");
break;
case "4":
System.out.println("****删除订单****");
System.out.println("请输入要删除的订单编号:");
int big = length;
for(int i = 0;i<length;i++) {
if(descs[i]==null) {
big = i;
break;
}
}
int no = 0;
do {
no = sc.nextInt();
if(no<1||no>big) {
System.out.println("不存在此编号菜品,请重新输入:");
}
} while (no<1||no>big);
if(status[no-1]==false) {
System.out.println("订单未完成,不能删除");
}else {
for(int i=no-1;i<length-1;i++) {
names[i] = names[i+1];
descs[i] = descs[i+1];
nums[i] = nums[i+1];
dates[i] = dates[i+1];
addresses[i] = addresses[i+1];
moneys[i] = moneys[i+1];
status[i] = status[i+1];
}
names[length-1] = null;
descs[length-1] = null;
nums[length-1] = 0;
dates[length-1] = 0;
addresses[length-1] = null;
moneys[length-1] = 0.0;
status[length-1] = false;
System.out.println("删除订单成功");
}
break;
case "5":
System.out.println("****我要点赞****");
System.out.println("序号\t菜名\t单价\t点赞数量");
int max = foods.length;
for(int i = 0;i<foods.length;i++) {
if(foods[i]==null) {
max = i;
break;
}
System.out.println((i+1)+"\t"+foods[i]+"\t"+prices[i]+"元\t"+zan[i]+"次");
}
System.out.println("请选择您要点赞的菜品编号:");
int bianhao = 0;
do {
bianhao = sc.nextInt();
if(bianhao<1||bianhao>max) {
System.out.println("不存在此编号菜品,请重新输入:");
}
} while (bianhao<1||bianhao>max);
zan[bianhao-1]++;
System.out.println("点赞成功,谢谢您的反馈");
break;
case "6":
System.out.println("****退出系统****");
System.out.println("谢谢使用");
break;
default:
System.out.println("选择错误,请重新选择:");
choose = sc.next();
break;
}
}while(!"6".equals(choose));
}
}