Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8889157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:11:37+00:00 2026-06-14T22:11:37+00:00

Update The first time the user makes a choice such as 1 the menu

  • 0

Update
The first time the user makes a choice such as “1” the menu is displayed again. The next time a selection is made the payment information begins to cycle. After the cycling is complete and the menu is displayed again, it works as it should. Also, the first two years are output instead of just the first when a selection begins to cycle, but then outputs one year at a time as intended.

//create scanner object for choosing a loan, then prompt for and accept input
    Scanner choose = new Scanner(System.in);
    String choice;
    System.out.println("\nType 1, 2, or 3 and press enter to see the monthly payment information for the respective loan. To end the program type \"end\".");
    choice = choose.next();

    //cycle loan 1 payment information
    //create scanner object to advance to the next year's payments

    //loop for cycling payment information
    //initialize loan principal to variable

    while (!"end".equals(choice)) {
        System.out.println("\nType 1, 2, or 3 and press enter to see the monthly payment information for the respective loan. To end the program type \"end\".");
        choice = null;
        choice = choose.next();
        if ("1".equals(choice)) {
           //calculation code
                    }
                if (j < 6) {
                    System.out.println("Press enter to get the mortgage information for year " + (j + 2));
                    choice = choose.nextLine();
                } else {
                    System.out.println("Congratulations, your mortgage has been paid off.");
                }

            }

            choice = null;
        }
        if ("2".equals(choice)) {
            //calculation code
                }
                if (j < 14) {
                    System.out.println("Press enter to get the mortgage information for year " + (j + 2));
                    choice = choose.nextLine();
                } else {
                    System.out.println("Congratulations, your mortgage has been paid off.");
                }

            }

            choice = null;
        }
        if ("3".equals(choice)) {
            //calculation code
                }
                if (j < 29) {
                    System.out.println("Press enter to get the mortgage information for year " + (j + 2));
                    choice = next.nextLine();
                } else {
                    System.out.println("Congratulations, your mortgage has been paid off.");
                }

            }

            choice = null;
        }
    }
    choose.close();
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:11:39+00:00Added an answer on June 14, 2026 at 10:11 pm

    I can see three issues upfront:

    1. You don’t need two scanners for System.in stream. Remove this statement Scanner next = new Scanner(System.in); and use the choose instance.

    2. If you close your input scanner as next.close();, it closes your input stream System.in as well and you may not be able read the stream again. Make sure you close the stream only when you are completely done with your program.

    3. Use equals method to compare the condition in while as while(!"end".equals(choice)). Put the literal "end" as first argument will take care of the null value of choice.

    EDIT:

    Your modified code at high level:

        Scanner choose = new Scanner(System.in);
        String choice= null;
        int j = 0;
        while (!"end".equals(choice)) {
            System.out.println("\nType 1, 2, or 3 and press enter to see the monthly payment information for the respective loan. To end the program type \"end\".");
            choice = choose.nextLine();
            if ("1".equals(choice)) {
               //calculation code
                   if (j < 6) {
                        System.out.println("Press enter to get the mortgage information for year " + (j + 2));
                        choice = choose.nextLine();
                    } else {
                        System.out.println("Congratulations, your mortgage has been paid off.");
                    }
                choice = null;
            }
            if ("2".equals(choice)) {
                    if (j < 14) {
                        System.out.println("Press enter to get the mortgage information for year " + (j + 2));
                        choice = choose.nextLine();
                    } else {
                        System.out.println("Congratulations, your mortgage has been paid off.");
                    }
                choice = null;
            }
            if ("3".equals(choice)) {
                    if (j < 29) {
                        System.out.println("Press enter to get the mortgage information for year " + (j + 2));
                        choice = choose.nextLine();
                    } else {
                        System.out.println("Congratulations, your mortgage has been paid off.");
                    }
                choice = null;
            }
        }
        choose.close();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In case user refuse to allow location update when on first time launch. how
I tried to update an fullcalendar event with updateEvent but only the first time
I've just used it for the first time - consider: IGameObject void Update() IDrawableGameObject
I am writing an iPhone game. When the user makes his first move a
On my android app, first time when app runs, user must type a license.
UPDATE: First problem solved, second one described at the bottom of this post. UPDATE2:
Is it possible to update first row and with WHERE clause. I Tried: UPDATE
I am trying to use an update query to update the first 3 characters
//how to use the N character to make my program update Arabic Fields (first
UPDATE: This is the working example. First we create a class to hold weekday,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.