1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
goldfiish [28.3K]
2 years ago
12

Java - Given a String variable response that has already been declared, write some code that repeatedly reads a value from stand

ard input into response until at last a Y or y or N or n has been entered.
ASSUME the availability of a variable, stdin , that references a Scanner object associated with standard input.
Computers and Technology
1 answer:
Rainbow [258]2 years ago
4 0

Answer:

import java.util.Scanner;

public class Main

{

public static void main(String[] args) {

   

    Scanner stdin = new Scanner(System.in);

    String response = "";

 while (true) {

     System.out.print("Enter the response: ");

     response = stdin.nextLine();

     

     if (response.equals("Y") || response.equals("y") || response.equals("N") || response.equals("n"))

         break;

 }

}

}

Explanation:

Create a string variable called response

Create a while loop that iterates until a condition is specified to stop

Inside the loop:

Ask the user for the input

Check if input equals "Y", "y", "N" or "n". If input equals any of these letters, stop the loop. Otherwise, continue asking for a new response

You might be interested in
Using complete sentences post a detailed response to the following.
laiz [17]

Answer:

some advantages of top down is that you can start off from what you know and figure out what you need to complete it, advantages to bottom up is that you can make something new . if you are starting something from scratch and you dont know what the end goal might be you would use bottom up but if you already have an idea or the final product of what you want you would go the top down approach.

Explanation: just saying you shouldnt just copy and paste my response but rather pick out what you want to say and use this to complete what ever your working on. hope i helped :)

6 0
2 years ago
Read 2 more answers
Mr. Yang is a doctor who regards video games as an effective means of staying fit. What type of game would he recommend to his p
morpeh [17]

Answer:

D. An exergame

Explanation:

It is because the exercise game is the suitable game to staying fit. For example wii video game able to give the similar experience to outdoor activities such as playing tennis, kick boxing etc.

8 0
3 years ago
Read 2 more answers
What customization feature can you use to create a cohesive look and feel for your presentations
yan [13]

B.Custom Themes

I have to add text so I can post this answer

5 0
3 years ago
This formatting option functions like a space bar. However, instead of moving one space at a time, it allows you to move your te
uysha [10]
Would it be Tab. I know that if you are in Microsoft word it works like that.<span />
3 0
3 years ago
Cotización de un software
Mashcka [7]

Answer:

translate it

Explanation:

3 0
3 years ago
Other questions:
  • Anna wants to open the Run dialog box to run her program file. Which keys should she press to open the Run dialog box?
    14·1 answer
  • Describe the general process of creating a DataFlow Diagram (DFD)
    7·1 answer
  • In steps<br> Urgent please
    14·1 answer
  • A hotel salesperson enters sales in a text file. Each line contains the following, separated by semicolons: The name of the clie
    11·1 answer
  • Which of the following is a popular open source intrusion detection system that runs on SmoothWall?? Synchronous Dynamic Random
    6·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    11·2 answers
  • An important goal of biosecurity training is to: Prevent laboratory accidents that could expose personnel to hazardous agents. P
    13·1 answer
  • Which one of the statements best characterizes the current state of e-commerce?
    15·1 answer
  • ASAP BRAINLIEST!!!!!!
    5·2 answers
  • You are trying to sell a new product to a store owner. Which method of presentation
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!