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
elixir [45]
3 years ago
14

Write a loop that reads strings from standard input where the string is either "land", "air", or "water". The loop terminates wh

en "xxxxx" (five x characters) is read in. Other strings are ignored. After the loop, your code should print out 3 lines: the first consisting of the string "land:" followed by the number of "land" strings read in, the second consisting of the string "air:" followed by the number of "air" strings read in, and the third consisting of the string "water:" followed by the number of "water" strings read in. Each of these should be printed on a separate line. Use the up or down arrow keys to change the height.
Computers and Technology
1 answer:
____ [38]3 years ago
4 0

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

You might be interested in
colby lives a very career-driven lifestyle. he works long hours and enjoys making a lot of money by working overtime. after he a
just olya [345]

The role of being a father will decrease Colby’s income and decrease the career-driven nature of his lifestyle.

8 0
3 years ago
Read 2 more answers
True or false? To help improve SEO, your URL should match the title of your blog post, word for word.
Vsevolod [243]

Improving SEO, by ensuring the URL matches the title of your

blog post, word for word is False.

<h3>What is SEO?</h3>

This is referred to as Search engine optimization. It is used to

improve a site by ensuring that is more visible when people

search for certain things or words.

The URL should contain only key words and unnecessary ones

should be eliminated which is why it isn't compulsory for the title

to be word for word.

Read more about Search engine optimization here brainly.com/question/504518

7 0
2 years ago
Which command let’s you increase or decrease the on-screen magnification of your document
JulijaS [17]
Ctrl - and ctrl +       i hope that is good for you                         
8 0
3 years ago
A developer designed a process in UiPath Studio that is best-suited for a simple and linear process. Which Studio workflow type
Gala2k [10]

Question options:

State Machine

Flowchart

Sequence

Global Exception Handler

Answer:

Sequence

Explanation:

Uipath is an RPA(Robotic process automation) software that is used by IT professionals and business executives in automating routine or iterative tasks in an organization. Uipath process projects incorporate different workflow types which include :sequence, flowchart, state machine and global exception handler. The sequence workflow type is used for simple linear projects that are not very complex and occupies a single activity block.

3 0
2 years ago
Write the definition of the function inputArray that prompts the user to input 20 numbers and stores the numbers into alpha. Wri
Alina [70]

Answer:

In Java:

public static  int[] inputArray(){

   Scanner input = new Scanner(System.in);

   int[] alpha = new int[20];

   for(int i = 0;i<20;i++){

       alpha[i] = input.nextInt();

   }

   return alpha;}

public static  int[] doubleArray(int [] alpha){

   int[] beta = new int[20];

   for(int i = 0;i<20;i++){

       beta[i] = 2 * alpha[i];

   }

   return beta;

}

public static int[] copyAlphaBeta(int [] alpha, int [] beta){

   int [] AlphaBeta = new  int[10];

   for(int i = 0;i<5;i++){

       AlphaBeta[i] = alpha[i];

   }

   int count = 5;

   for(int i = 15;i<20;i++){

       AlphaBeta[count] = beta[i];

       count++;

   }

   return AlphaBeta;

}

public static void printArray(int [] alpha){

   for(int i = 0;i<20;i++){

       System.out.print(alpha[i]+" ");

       if((i+1)%15 == 0){

           System.out.println(" ");

       }

   }

}

Explanation:

The inputArray is defined here

public static  int[] inputArray(){

   Scanner input = new Scanner(System.in);

This declares alpha array of 20 elements

   int[] alpha = new int[20];

The following iteration gets input from the user into the array

<em>    for(int i = 0;i<20;i++){</em>

<em>        alpha[i] = input.nextInt();</em>

<em>    }</em>

This returns the alpha array

   return alpha;}

The doubleArray is defined here. It takes the alpha array as its input parameter

public static  int[] doubleArray(int [] alpha){

This declares beta of 20 integers

   int[] beta = new int[20];

This populates beta by 2 * alpha[i]

<em>    for(int i = 0;i<20;i++){</em>

<em>        beta[i] = 2 * alpha[i];</em>

<em>    }</em>

This returns the alpha array

   return beta;}

The copyAlphaBeta array is defines here

public static int[] copyAlphaBeta(int [] alpha, int [] beta){

This declares AlphaBeta as 10 elements

   int [] AlphaBeta = new  int[10];

This populates the first 5 elements of AlphaBeta with the first 5 of alpha

<em>    for(int i = 0;i<5;i++){</em>

<em>        AlphaBeta[i] = alpha[i];</em>

<em>    }</em>

   int count = 5;

This populates the last 5 elements of AlphaBeta with the last 5 of beta

<em>    for(int i = 15;i<20;i++){</em>

<em>        AlphaBeta[count] = beta[i];</em>

<em>        count++;</em>

<em>    }</em>

This returns the AlphaBeta array

   return AlphaBeta;

}

The printArray is defined here. It takes the alpha array as its input parameter

public static void printArray(int [] alpha){

This iterates through alpha array

   for(int i = 0;i<20;i++){

This prints each element of the array

       System.out.print(alpha[i]+" ");

A new line is started after the 15th element

<em>        if((i+1)%15 == 0){</em>

<em>            System.out.println(" ");</em>

<em>        }</em>

   }

}

See attachment for complete program which includes the main

Download txt
4 0
2 years ago
Other questions:
  • (01.03 LC)
    9·1 answer
  • Both the Alphabetic Index and the Tabular List must be used to locate and assign a diagnosis code in ICD-10-CM. Group of answer
    7·1 answer
  • ________________is a distribution of Linux Operating<br>system for desktop computers.<br>​
    15·1 answer
  • Security Definition updates for windows defender are performed through the ——— function in windows server 2016
    7·2 answers
  • Display the total number of parking tickets.
    5·1 answer
  • Which symbol is at the beginning and end of a multiline comment block? ### &amp;&amp;&amp; %%% """
    14·1 answer
  • PLEASE I NEED HELP FAST
    8·1 answer
  • Discuss the term internal control​
    12·1 answer
  • What number is represented as a binary code of 101110
    5·2 answers
  • Why does Homework exist? Why is it so important?
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!