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
Write a function named swapFrontBack that takes as input a vector of integers. The function should swap the first element in the
kondaur [170]

Answer:

#include <iostream>

#include <vector>

using namespace std;

void swapFrontBack(vector<int>& nums) {

if(nums.size() < 2) {

return;

}

swap(nums[0], nums[nums.size()-1]);

}

void printit(vector<int>& arr) {

for(int i = 0; i < arr.size(); i++) {

cout << arr[i] << " ";

}

cout << endl;

}

int main() {

vector<int> num1;

swapFrontBack(num1);

printit(num1);

num1.push_back(1);

swapFrontBack(num1);

printit(num1);

num1.push_back(2);

swapFrontBack(num1);

printit(num1);

vector<int> num2(10, 1);

num2[9] = 2;

swapFrontBack(num2);

printit(num2);

return 0;

}

Explanation:

4 0
3 years ago
A group of small local businesses have joined together to share access to a cloud-based payment system. Which type of cloud is m
Valentin [98]

The type of cloud that is most likely being implemented when a group of small local businesses has joined together to share access is community cloud service. The correct option is C.

<h3>What is cloud service?</h3>

Cloud services have a wide variety of services for companies and businesses. They provide applications and software with resources. They provide easy and affordable services.

Community cloud service is a shared type of cloud service that helps banks and heads of trading firms.

Thus, the correct option is C. Community.

To learn more about cloud service, refer to the below link:

brainly.com/question/24227961

#SPJ1

The question is incomplete. Your most probably complete question is given below:

Public

Private

Community

Hybrid

6 0
2 years ago
What internal commands can we use when in interactive mode? can we use CLS and CD?
krok68 [10]
The cd command, also known as chdir (change directory), is a command-line shell command used to change the current working directory in various operating systems. It can be used in shell scripts and batch files.
3 0
3 years ago
You decide to begin your presentation by providing your audience an overview of networking, with an emphasis on security and why
Debora [2.8K]

Answer:

Please see attachment for differentiation.

6 0
3 years ago
Which quality determines an individual's ability to be open to changes and complete tasks in an ever-changing work environment?
MrMuchimi

Answer

Flexibility

Explanation:

8 0
3 years ago
Other questions:
  • Explain how abstraction is used in a GPS system
    12·2 answers
  • The function takes two string parameters; the first is the name of a file and the second is text. Complete the function to appen
    7·1 answer
  • Pick an appliance or an electronic device that you use at home that is powered from the wall outlet. Specify which electronics d
    10·1 answer
  • Suppose for the worst case, given input size n: Algorithm 1 performs f(n) = n2 + n/2 steps Algorithm 2 performs f(n) = 12n + 500
    6·1 answer
  • ARP only permits address resolution to occur on a single network.could ARP send a request to a remote server in an IP datagram?w
    9·1 answer
  • Write a program that asks the user how many numbers will be entered and then has the user enter those numbers. When this is done
    7·1 answer
  • Kali, a Python programmer, is using the turtle module to write the word "hello." Which code should she use to indicate the locat
    9·2 answers
  • Hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
    14·2 answers
  • Dis-cord and/or snap????????????? Im 13 ! and a girl :)))))
    12·2 answers
  • If consumers start to believe they need a product, what is likely to happen
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!