2014-09-26 99 views
-1

基本上我只需要小费计算器程序的帮助。它应该询问有多少客户,使用的小费百分比,每位顾客的账单金额,小费金额以及小费金额均匀分配给每位顾客。我还试图让程序阅读尽可能多的客户,以便用户输入红利作为功课。这里是代码,而不是返回“请输入他们的账单数额”的程序,我不断收到“是否有另一位客户?Y或N?”。这是我遇到的主要问题。不好意思,我基本上是一个完整的初学者。Java小技巧计算器

import java.util.Scanner; 

public class H3_TipCalc { 
    public static void main(String[] args) { 
     Scanner input = new Scanner (System.in); 
     System.out.println("Please enter your bill amount."); 
     double bill = input.nextDouble(); 
     { 
     String multiplecust = ("Y"); 

     //int mc = 1; 
     while (multiplecust.equalsIgnoreCase("y")) 
     { 
      Scanner usrin = new Scanner (System.in); 
      System.out.println("Is there another customer? y or n?"); 
      multiplecust = usrin.nextLine(); 
      //mc++; 
      if (usrin.equals("y")) 
      { 
       System.out.println("Please enter their bill amount."); 
      } 
     } 
     } 
    } 
} 

回答

0
if (usrin.equals("y")) 
    { 
     System.out.println("Please enter their bill amount."); 
    } 

你比较Scanner"y",这可能不是你要比较的。比较multiplecust"y"