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
kirill115 [55]
3 years ago
14

Write a fragment of code that will read words from the keyboard until the word done is entered. For each word except done, repor

t whether its first character is equal to its last character. For the required loop, use a:_________.
a) while statement.
b) do-while statement.
Computers and Technology
1 answer:
hram777 [196]3 years ago
8 0

Answer:

a)

Scanner keyboard = new Scanner(System.in);

System.out.println("Enter a word");

String word = keyboard.next();

while(!word.equals("done"))

{

if(word.charAt(0) == word.charAt(word.length() - 1))

{

System.out.println("First and last character are equals for the word: " + word);

}

else

{

System.out.println("First and last character are NOT equals for the word: " + word);

}

word = keyboard.next();

}

b)

Scanner keyboard = new Scanner(System.in);

System.out.println("Enter a word");

String word = keyboard.next();

do

{

if(word.charAt(0) == word.charAt(word.length() - 1))

{

System.out.println("First and last character are equals for the word: " + word);

}

else

{

System.out.println("First and last character are NOT equals for the word: " + word);

}

word = keyboard.next();

}while(!word.equals("done"));

Next time note what language you are distributing programming with :)

You might be interested in
application that will perform a lot of overwrites and deletes of data and requires the latest information to be available anytim
o-na [289]

Answer:

RDS.

Explanation:

A corporation has implemented a software that conducts the number of information overwriting and deleting, which allows the newest details to be accessible whenever the information is examined. As a Software Engineer, they suggest RDS database technologies.

It is an AWS supported controlled SQL DB service that also reinforces the array type DB for the purpose to contain and maintain the information.

3 0
3 years ago
Write a loop that reads strings from standard input where the string is either "land", "air", or "water". The loop terminates wh
____ [38]

Answer:

count_land = count_air = count_water = 0

while True:

   s = input("Enter a string: ")

   if s == "xxxxx":

       break

   else:

       if s == "land":

           count_land += 1

       elif s == "air":

           count_air += 1

       elif s == "water":

           count_water += 1

print("land: " + str(count_land))

print("air: " + str(count_air))

print("water: " + str(count_water))

Explanation:

*The code is in Python

Initialize the variables

Create a while loop that iterates until a specific condition is met. Inside the loop, ask the user to enter the string. If it is "xxxxx", stop the loop. Otherwise, check if it is "land", "air", or "water". If it is one of the given strings, increment its counter by 1

When the loop is done, print the number of strings entered in the required format

4 0
3 years ago
Power point 2016 which chart element provides the boundaries of the graphic?
SVEN [57.7K]
D. (chart elemments) - correct answer
8 0
3 years ago
Eye injuries usually occur as a result of all of the following things, EXCEPT:
alexdok [17]

The correct answer is A I believe.

3 0
3 years ago
Read 2 more answers
The interactive process through which people learn the basic skills, values, beliefs, and behavior patterns of a society.
irina1246 [14]
The answer is : Socialization

the interactive process through which people learn the basic skills, values, beliefs, and behavior patterns of a society is called Socialization
During socialization process, a person tend to understand what is acceptable in the society and which is not. During the process, a person could also discover various unique characteristics from each individual
6 0
3 years ago
Other questions:
  • Although the battery on your smartphone is fully charged, it drains quickly. In some instances when the phone shows that the bat
    12·1 answer
  • Write a program that prompts the user to enter the weight of a person in kilograms and outputs the equivalent weight in pounds.
    8·1 answer
  • Antifreeze is not considered a hazardous waste by the EPA unless it is used or otherwise becomes contaminated.
    13·2 answers
  • The overall visual look of a chart in terms of its graphic effects, colors, and backgrounds is the:
    5·1 answer
  • Select the correct answer.
    6·2 answers
  • John travels a lot and he needs to access his documents and services on the go. Which of these technologies allows his to access
    5·1 answer
  • Suppose there is a class Alarm. Alarm has two class variables, code which contains a String value representing the code that dea
    12·1 answer
  • Does anyone know how to change your username? plz help I don't want my name on this lmo
    8·2 answers
  • How do you do 1.17.5, invert colors, on codehs?
    10·1 answer
  • What should you do when you are working on an unclassified system and receive an email.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!