这是我的代码:
public class Pizza {
public static void main(String[] args) {
int orderDone = 1;
//declare variables
while(orderDone == 1){
int done = 1;
double total2 = 0;
final int DELIVERY_COST = 3;
double pizzaPrice = 8.50;
String customerAddress = null;
String customerNumber = null;
int pizzaQuantity = 0;
//my code
orderDone = readInt("Would you like to make another order? (0 - yes 1 - no) ");
if(orderDone == 1){
orderDone = 2;
} else {
done = 0;
}
最佳答案
这里:你混淆了 1 和 0。另外,最后没有使用额外的 if 和 else 语句。
public class Pizza {
public static void main(String[] args) {
int orderDone = 0;
//declare variables
while(orderDone == 0){
int done = 1;
double total2 = 0;
final int DELIVERY_COST = 3;
double pizzaPrice = 8.50;
String customerAddress = null;
String customerNumber = null;
int pizzaQuantity = 0;
//my code
orderDone = readInt("Would you like to make another order? (0 - yes 1 - no) ");
}
}
// reset of the code
}
关于java - 如果用户这么说,如何让我的代码再次循环?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24544363/