2014-09-26 71 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"