questions are as follows:
import java.util.Scanner;
import com.sun.org.apache.xerces.internal.util.SynchronizedSymbolTable;
public class Restaurant_system {
public static void main(String[] args) {
/**
*/
/*, */
String[]name = new String[4]; //
String[]dishMegs = new String[4];//
int[]times = new int[4];//
String[]addresses = new String[4];//
int[]states = new int[4];//:01
double[]sumPrices1 = new double[4];//
final double SEND_PRICES = 5.;
double[]sumPrices = new double[4];//
//boolean end = false; do-while
String button;
Scanner input = new Scanner(System.in);
int choose;
do {
int check = 0;//
int check_ok = 0;//
//
System.out.println(""" ");
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.print("\n:");
choose = input.nextInt(); //
switch (choose) {
case 1:
System.out.println("******");
//
for(;check < name.length;checkPP){//
if (name[check] !=null){//
check_ok += 1;//1
}else{//
break;
}
}
if (check_ok == 4) {//
System.out.println("");
//
}else{//
System.out.print(":");
name[check_ok] = input.next();//
System.out.println("\t\t\t");
System.out.println("1\t\t38.0\t0");
System.out.println("2\t\t20.0\t0");
System.out.println("3\t\t10.0\t0");
}
System.out.print(":");
int number = input.nextInt();
System.out.print(":");
int copies = input.nextInt();
switch (number) {
case 1:
dishMegs[check_ok] = "" +copies + "";
sumPrices1[check_ok] = 38 * copies;
break;
case 2:
dishMegs[check_ok] = "" +copies + "";
sumPrices1[check_ok] = 20 * copies;
break;
case 3:
dishMegs[check_ok] = "" +copies + "";
sumPrices1[check_ok] = 10 * copies;
break;
default:
System.out.println("1-3");
break;
}
if (sumPrices1[check_ok] < 50) {
sumPrices[check_ok] = sumPrices1[check_ok] + SEND_PRICES;
}
System.out.println("1020:");
boolean time_check_ok = true; //
do {
int time_check = input.nextInt();
if (time_check <= 20 && time_check>= 10) {
times[check_ok] = time_check;
time_check_ok = false;
}else {
System.out.println(":");
}
} while(time_check_ok);
System.out.println(":");
addresses[check_ok] = input.next();
System.out.println("");
System.out.println(":" + dishMegs[check_ok]);
System.out.println(":" + times[check_ok]);
System.out.println(":" + addresses[check_ok]);
System.out.println(":" + sumPrices1[check_ok] + ":" + SEND_PRICES + ":" + sumPrices[check_ok] + "");
break;
case 2:
System.out.println("******");
System.out.println("\t\t\t\t\t\t");
for(;check < name.length;checkPP){//
if (name[check] !=null){//
check_ok += 1;//1
}else{//
break;
}
}
for (int serialNumber = 0; serialNumber < check_ok; serialNumberPP) {
System.out.println((serialNumber+1) + "\t" + name[serialNumber] + "\t" + dishMegs[serialNumber] + "\t" +
times[serialNumber] + "\t" + addresses[serialNumber] + "\t" + sumPrices[serialNumber] + "\t" + states[serialNumber]);
}
break;
case 3:
System.out.println("");
break;
case 4:
System.out.println("");
break;
case 5:
System.out.println("");
break;
case 6:
System.out.println("");
break;
default:
System.out.println("1-6");
break;
}
//System.out.print("y:");
//button = input.next();//
} while (true );
//button.equals("y")
}
}
this code content is not the point
the point is that every time I am asked to type
such as nextInt ()
I enter a 1
often give me an error report:
looked it up on the Internet and said that the type of input did not match the type of reception, so it caused an error.
that is to say, it is quite possible that the 1 I typed was thought by the system to be the 1 of a string and then collapsed
I often encounter this problem. I would like to ask all the great gods how to solve this problem.