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 8766503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:34:12+00:00 2026-06-13T16:34:12+00:00

Trying to write a program that asks the user if they want instructions. If

  • 0

Trying to write a program that asks the user if they want instructions. If the user enters maybe the console responds with “please enter a yes or no answer” and repeats the question.

I’m having difficulty listing the method parameters for the method askYesNoQuestion. Are the parameters simply String yes, String no? I am also stuck on how do I make the program repeat the question after someone enters maybe? Does my code look generally correct for what I’m trying to do?

import acm.program.*;



public class Instructions extends ConsoleProgram{

    public void run(){
        String answer  = readLine("Would you like instructions? : ")
        {
            if (answer.equals("maybe")) {
                println ("Please enter a yes or no answer.");  
            }
        }
    }   

    private boolean askYesNoQuestion(String yes, String no ){

        if (askYesNoQuestoin ("would you like instructions? "))
            if (answer.equals("yes")) {
                return yes;
            } else {
                if (answer.equals("no"))
                    return no;
            }
    }
  • 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-13T16:34:13+00:00Added an answer on June 13, 2026 at 4:34 pm

    Up to you how you do it, but really you are trying to convert a user’s string input to something a bit easier for Java to work with.

    I’d suggest askYesNoQuestion() would take the question to ask and then return true for yes and false for no. If you really want to handle “maybe” then use and int (or better yet an enum) to handle the response.

    boolean askYesNoQuestion(String question)
    {
         while(true) {
         // print the question
         // get the answer
         // if answer.equals("yes") return true 
         // if answer.equals("no") return false
         // any other answer asks the question again
         }
         return false;
    }
    
    // call looks like
    if (askYesNoQuestion("Do you want instructions?")) {
      // do instructions
    }
    // Do the rest of the app.
    // 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a program that asks the user to enter a password
I am trying to write a program that asks a user for a ten
Hello I am trying to write a program in python that asks the user
i am trying to write a program that prompts the user to enter a
I'm trying to write a small program that asks a user to input a
I am trying to write a program that will prompt you to enter someone's
I have been trying to write some code that asks the user for several
I am currently trying to write a program which asks the user for a
Im trying to write a program that runs some shell commands wit emulated user
I'm trying to write a program that would convert celcius to fahrenheit and visa-versa.

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.