dimanche 21 février 2016

while loop not working in Java

I am trying to get this to ask the question over and over again while the user inputs a 'Y'. and stop and return the Event.displayFinalResults(); when the user inputs a 'N'

i am getting a continuous loop right now. I am missing something or my layout it wrong. Any help would be great.

            System.out.println("Is there anymore amounts you want to add?(Y/N): ");
            Scanner keyboard = new Scanner(System.in);
            char choice = keyboard.next().charAt(0);
            choice = Character.toUpperCase(choice);
            if(choice == 'Y')
            {
                do
                {
                    System.out.println("Is there anymore amounts you want to add?(Y/N): ");
                    choice = keyboard.next().charAt(0);
                    choice = Character.toUpperCase(choice);

                    readValidateAmountType();
                    readValidateAmount(); 
                }
                while(choice =='Y');

            }
            else
            {
                Event.displayFinalResults();
            }

thanks again.

Aucun commentaire:

Enregistrer un commentaire