为什么会显示“选择”两次? [英] Why does it show "Choose" twice?
本文介绍了为什么会显示“选择”两次?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
import java.util.Scanner;
public class Steam{
public static void main(String[] args){
int i=0,j=0;
Scanner input = new Scanner(System.in);
double ac[]={3,5,1.5,2};
double a[] = new double[100];
String cont, choose;
double pay=0, hour=0;
do{
pay=0;
System.out.println("Select the following: ");
System.out.println("1. steam & sauna ($3)");
System.out.println("2. Massage ($5)");
System.out.println("3. Soft Drink ($1.5)");
System.out.println("4. Fast Food ($2)");
System.out.println("5. Payment");
System.out.println("6. Exit");
do{
System.out.print("Choose: ");
choose=input.nextLine();
if(choose.equalsIgnoreCase("6")) break;
if(choose.equalsIgnoreCase("1")){
a[0]=ac[0];
}else if(choose.equalsIgnoreCase("2")){
a[0]=0;
System.out.print("Input hour(s): ");
hour=input.nextDouble();
a[1]=ac[1]*hour;
}else if(choose.equalsIgnoreCase("3")){
a[2]=ac[2];
}else if(choose.equalsIgnoreCase("4")){
a[3]=ac[3];
}else if(choose.equalsIgnoreCase("5")){
for(j=0; j<i; j++){
pay+=a[j];
a[j]=0;
}
System.out.println("\nTotal Payment: $"+ pay);
break;
}
i++;
}while(true);
if(choose.equalsIgnoreCase("6")) break;
System.out.print("Do you want to continue? (y/n): ");
cont=input.nextLine();
}while(cont.equalsIgnoreCase("y"));
}
}
推荐答案
3));
系统。< span class =code-keyword> out .println( 2.按摩(
3)"); System.out.println("2. Massage (
5));
系统。 out .println( 3.软饮料(
5)"); System.out.println("3. Soft Drink (
1.5));
系统。 out .println( 4.快餐(
1.5)"); System.out.println("4. Fast Food (
这篇关于为什么会显示“选择”两次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文