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
Given three packets of size 2,500 Bytes (caution this is Bytes not bits) each are ready inside computer 1 to be transmitted onto
gizmo_the_mogwai [7]

Answer: umm sorry

Explanation:

5 0
3 years ago
To join two or more objects to make a larger whole is to _____________ them.
Masja [62]
C. Integrate is the answer PLZ MARK AS BRAINLIEST
6 0
3 years ago
Read 2 more answers
Routers do not forward broadcast packets.A. TrueB. False
mestny [16]
The answer you’re looking for is false
5 0
3 years ago
Need the answer ASAP plz !!!!!
Evgesh-ka [11]
Performance would be the answer
3 0
3 years ago
(ATRCKALLB) __________is an input device that contains a movable ball on the top.​
nikitadnepr [17]

Answer:

trackball

Explanation:

A trackball can be seen on a mouse.

3 0
2 years ago
Other questions:
  • PLEASE HURRY What data unit is addressed based on the IP address of the recipient? a. packet b. frame c. segment d. section
    9·2 answers
  • Write a program reverse-order.cpp which asks the user to input two dates (earlier date then later date). The program should repo
    13·1 answer
  • ___ is a career discipline focusing on helping companies use computer technology effectively.
    12·1 answer
  • What term best describes the way the dns name space is organized?
    9·1 answer
  • Students who respond promptly to e-mails are following which netiquette rule?
    13·2 answers
  • From the Software Engineering Code of Ethics, which clauses relate to intellectual property (check all that apply)
    15·1 answer
  • What made it possible to develop personal computers?
    10·2 answers
  • What do computer programs generally try to solve and how? A) Computer programs generally try to solve a well-defined problem usi
    14·1 answer
  • Specific keys that each finger is responsible for typing is called A. ergonomics B. Touch typing C. Key reaches D. Posture
    8·1 answer
  • Hyperlink is a term used to refer to the specific manner of specifying the address of a website. Write reason for true or false.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!