title: JAVA Do-while switch prints menu twice display error
body: <p>This is my first question!</p>
  
  <p>My do-while menu loop does not repeat properly. </p>
  
  <p>It seems to print the default option in the switch every time it repeats after the user has input info into option A or B (Not when X 'exiting'. Rather than going back to the main menu the default switch is printed too along with the another main menu...</p>
  
  <p>It is like it has received an invalid input but no input has been given!</p>
  
  <p>This is my code: </p>
  
  <pre><code>import java.util.Scanner;
  
  public class Part3Final
  {
  
        static double rateM = 1.40;
        static double rateC = 2.40;
        static double rateLCV = 3.80;
        static double rateHCV = 7.20;
  
        static String M = "M";
        static String C= ("C");
        static String LCV ="LCV";
        static String HCV = ("HCV");
  
        static String Peak = "Peak";
        static String offPeak = "Off-Peak";
        static String Night = "Night"   ;      
  
        public static void main(String[] args)
        {
  
           Scanner sc = new Scanner(System.in);
  
           System.out.print("\nEnter Vehicle Type (M, C, LCV, HCV):");
           String vehicleType = sc.nextLine();
  
           if (vehicleType.equals(HCV))
              System.out.print("Enter Trip Time (Peak, Off-Peak or Night):");
              String tripTime = sc.nextLine();     
  
           String choiceEntry;
  
           String tripDetails="";
           String tripList= "";
  
           int sectors;
  
        // Adjusted rate calculation
           double adjustedHCVNight = (7.2 - (rateHCV*0.3));
           double adjustedHCVPeak = ((rateHCV*0.4)+7.2);
        // Variables to alter later
           double adjustedSectorRate = 100;
           double tripRate = 0;
           double tripCharge= 0;
           double totalCharge=0;
  
           String breakList = "";
           String breakReport = "";
  
           double totalBreakCharge = 0;
  
         //b  char choiceEntryCh = '\0';
  
           do   
           {
              System.out.println("\nToll Road Data Entry Menu");
              System.out.println("-----------------------------------------");
              System.out.println("\nA - First Option");
              System.out.println("B - Second Option");
              System.out.println("X - Exit");
  
              System.out.print("\nEnter your selection: ");
              choiceEntry = sc.nextLine();
              choiceEntry = choiceEntry.toUpperCase(); 
  
              if (choiceEntry.length() != 1)
                 System.out.println("Response must be a single character!");
              else
  
                 switch (choiceEntry)
                 {
                 // equivalent of doing if (selection == 'A' || selection == 'a')
                    case "A":
                    case "a":
                    { 
                       System.out.print("Enter Trip Date:");
                       String tripDate = sc.nextLine();
                       System.out.print("Enter Entry Point:");
                       int entryPoint = sc.nextInt();
                       System.out.print("Enter Exit Point:");
                       int exitPoint = sc.nextInt();
  
                       sectors= Math.abs(exitPoint-entryPoint);
  
                       if (tripTime.equals(Peak))
                             tripRate=(adjustedHCVPeak);             
                       if (tripTime.equals(Night))
                             tripRate= (adjustedHCVNight) ;
                       if (tripTime.equals(offPeak))
                             tripRate= (rateHCV);
  
                       if  (vehicleType.equals(M))
                             tripRate = rateM;
                       if (vehicleType.equals(C))
                             tripRate = rateC;
                       if (vehicleType.equals(LCV))
                             tripRate = rateLCV;
  
                       tripCharge= (tripRate * sectors);
  
                       tripDetails = String.format("%s %s %s %d %s %d %s %.2f %s %.2f %s", "- Trip on", tripDate, "from sector", entryPoint, "to sector", exitPoint, "at rate", tripRate, "(toll charge:", tripCharge,")");
  
                       tripList= (tripList + "\n" + tripDetails);
  
                       totalCharge= (totalCharge + tripCharge);
                       }
                       break;
  
                    case "B":
                    case "b":
                    {
                       System.out.print("\nEnter Breakdown Incident Date:");
                       String incidentDate = sc.nextLine();
                       System.out.print("Enter sector breakdown occured in:");
                       int breakdownPoint = sc.nextInt();
                       System.out.print("Enter vehicle recovery cost:");
                       double recoveryCost = sc.nextDouble();
  
                       breakReport = String.format("%s %s %s %d %s %.2f %s", "- Breakdown on", incidentDate, "in sector", breakdownPoint, "(recovery cost:", recoveryCost,")");
  
                       breakList= (breakList + "\n" + breakReport);
  
                       totalBreakCharge= (totalBreakCharge + recoveryCost);
  
                    }
                       break;
  
                    case "X":
                    case "x":
                       System.out.println("Exiting data entry menu...");
                       break;
  
                    default:
                       System.out.println("Error - invalid selection!");
                       break;
  
  
                    }     
  
            }while (!choiceEntry.equalsIgnoreCase("X"));
              //if (choiceEntry.equals("X"))
                //a System.out.println("Exiting data entry menu...");
  
  
           System.out.printf("\n%-70s %s\n", "Toll Charges:\n", tripList);
  
           System.out.printf("\n%s %.2f %s", "(Toll charge total: $",totalCharge,")");
  
           System.out.printf("\n%-70s %s\n", "\nBreakdown Charges:\n", breakList);
  
           System.out.printf("\n%s %.2f %s", "(Breakdown charge total: $",totalBreakCharge,")");
  
           double totalInvoice= (totalCharge + totalBreakCharge);
  
           System.out.printf("\n%-70s %.2f\n", "\nToll Invoice Total", totalInvoice);
  
  
           }
  
  
        }
  </code></pre>
  
  <p>This is print out I get <strong>BOLDED</strong> is the error:</p>
  
  <p>Enter Vehicle Type (M, C, LCV, HCV):HCV
  Enter Trip Time (Peak, Off-Peak or Night):Night</p>
  
  <p>Toll Road Data Entry Menu</p>
  
  <p>A - First Option
  B - Second Option
  X - Exit</p>
  
  <p>Enter your selection: A
  Enter Trip Date:6
  Enter Entry Point:5
  Enter Exit Point:3</p>
  
  <p><strong>Toll Road Data Entry Menu
  A - First Option
  B - Second Option
  X - Exit
  Enter your selection: Response must be a single character!</strong></p>
  
  <p><em>NOTE NO RESPONSE HAS BEEN INPUT</em></p>
  
  <p>Toll Road Data Entry Menu</p>
  
  <p>A - First Option
  B - Second Option
  X - Exit</p>
  
  <p>Enter your selection: a
  Enter Trip Date:5/4/2017
  Enter Entry Point:5
  Enter Exit Point:2</p>
  
  <p><strong>Toll Road Data Entry Menu
  A - First Option
  B - Second Option
  X - Exit
  Enter your selection: Response must be a single character!</strong></p>
  
  <p><em>NOTE NO RESPONSE HAS BEEN INPUT</em></p>
  
  <p>Toll Road Data Entry Menu</p>
  
  <p>A - First Option
  B - Second Option
  X - Exit</p>
  
  <p>Enter your selection: x
  Exiting data entry menu...</p>
  
  <p>Toll Charges:</p>
  
  <ul>
  <li>Trip on 6 from sector 5 to sector 3 at rate 5.04 (toll charge: 10.08 )</li>
  <li>Trip on 5/4/2017 from sector 5 to sector 2 at rate 5.04 (toll charge: 15.12 )</li>
  </ul>
  
  <p>(Toll charge total: $ 25.20 )</p>
  
  <p>Breakdown Charges:</p>
  
  <p>(Breakdown charge total: $ 0.00 )</p>
  
  <p>Toll Invoice Total                                                    25.20</p>
  
  <p>Can someone please explain why this is happening! </p>
  
  <p>Thank you!      </p>