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]
3 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]3 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
Which are examples of digital video? Choose all that apply.
Cerrena [4.2K]

Answer:

video downloaded from a website and played on a portable electronic device

Explanation:

8 0
3 years ago
Read 2 more answers
Which remarketing audiences can be defined in google analytics? (select all that apply)?
Harman [31]
<span>The remarketing audiences that can be defined in google analytics are :      </span><span>
1) Users who played a video on your website
2) Users who purchased a product on your website
</span>3) Users who visited a specific page on your website
3 0
3 years ago
Which option would you use to insert two line breaks in your document?
sesenic [268]

I would go for <br/><br/>.

5 0
3 years ago
Read 2 more answers
Which type of processing best describes the correction of errors or the rearrangement of a job's running time?
Neko [114]

Answer:

Real-time

Explanation:

i am sure because on my test it said corect

6 0
4 years ago
Một số được gọi là thác đổ nếu phần tử biểu diễn thập phân của nó nhiều hơn một chữ số đồng thời theo chiều từ trái qua phải chữ
kirza4 [7]
I don’t understand this
3 0
3 years ago
Other questions:
  • What type of engine is common on boats designed for shallow water?
    13·1 answer
  • Write an application program that creates and prints a random phone number of the form XXX-XXX-XXXX. Include the dashes in the o
    5·1 answer
  • 6. Data are given in comma delimited text file for a toy rocket. The rocket is powered by pressurized water that is discharged f
    14·1 answer
  • What are the components inside the case typically draw power from a cable connected to the motherboard instead of being connecte
    6·2 answers
  • Where do players resurrect if they have been destroyed in a game?
    13·1 answer
  • What are digital forensic techniques? A. Identifying, extracting, and evaluating evidence obtained from digital media such as co
    11·1 answer
  • PLZ ANSWER THESE QUESTIONS FOR 30 POINTS AND BRAINLIEST!
    9·1 answer
  • In Scheme, source code is data. Every non-atomic expression is written as a Scheme list, so we can write procedures that manipul
    8·1 answer
  • Select the correct answer.
    7·1 answer
  • A(n) ____ is a live internet presentation that supports interactive communications between the presenter and the audience.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!