answer.
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
Ivahew [28]
2 years ago
7

Write a loop that reads strings from standard input, where the string is either duck or goose. the loop terminates when goose is

read in. after the loop, your code should print out the number of duck strings that were read.
Computers and Technology
1 answer:
Misha Larkins [42]2 years ago
4 0
Have in mind that the following code is ofr C++ but I know that whatever the language you are using, you can use the same idea:

<span><iostream> 
using namespace std; 
int main() 
{ 
int count=0; 
string x; 
while(1) 
{ 
cout<<"Enter either goose or duck"; 
cin>>x; 
if ( x=="Goose") break; 
count++; 
} 

cout<<"Number of Ducks="<<count<<endl; 
return 0; 
}
</span>
Another one that is simplier but the language is python is:
counter = 0while True:  line = input()if line == 'duck':  counter += 1    elif line == 'goose':breakprint(counter)
You might be interested in
You are consulting for a trucking company that does a large amount ofbusiness shipping packages between New York and Boston. The
likoan [24]

Answer:

Answer explained with detail below

Explanation:

Consider the solution given by the greedy algorithm as a sequence of packages, here represented by indexes: 1, 2, 3, ... n. Each package i has a weight, w_i, and an assigned truck t_i. { t_i } is a non-decreasing sequence (as the k'th truck is sent out before anything is placed on the k+1'th truck). If t_n = m, that means our solution takes m trucks to send out the n packages.

If the greedy solution is non-optimal, then there exists another solution { t'_i }, with the same constraints, s.t. t'_n = m' < t_n = m.

Consider the optimal solution that matches the greedy solution as long as possible, so \for all i < k, t_i = t'_i, and t_k != t'_k.

t_k != t'_k => Either

1) t_k = 1 + t'_k

    i.e. the greedy solution switched trucks before the optimal solution.

    But the greedy solution only switches trucks when the current truck is full. Since t_i = t'_i i < k, the contents of the current truck after adding the k - 1'th package are identical for the greedy and the optimal solutions.

    So, if the greedy solution switched trucks, that means that the truck couldn't fit the k'th package, so the optimal solution must switch trucks as well.

    So this situation cannot arise.

  2) t'_k = 1 + t_k

     i.e. the optimal solution switches trucks before the greedy solution.

     Construct the sequence { t"_i } s.t.

       t"_i = t_i, i <= k

       t"_k = t'_i, i > k

     This is the same as the optimal solution, except package k has been moved from truck t'_k to truck (t'_k - 1). Truck t'_k cannot be overpacked, since it has one less packages than it did in the optimal solution, and truck (t'_k - 1)

     cannot be overpacked, since it has no more packages than it did in the greedy solution.

     So { t"_i } must be a valid solution. If k = n, then we may have decreased the number of trucks required, which is a contradiction of the optimality of { t'_i }. Otherwise, we did not increase the number of trucks, so we created an optimal solution that matches { t_i } longer than { t'_i } does, which is a contradiction of the definition of { t'_i }.

   So the greedy solution must be optimal.

6 0
2 years ago
What technique creates different hashes for the same password? ccna routing protocols final answers?
elena-s [515]
The answer is Salted Password Hashing.  The process is similar to hashing., but with a twist. A random value is introduced for each user. This salt value<span> is included with the password when the hash value is calculated and is stored with the user record. Including the salt value means that two users with the same password will have different password hashes.</span>
7 0
2 years ago
Which element of the word program window contains buttons for saving a document and for undoing, redoing, and repeating a change
miskamm [114]
The answer is the Quick Access Toolbar. However, it is not only for saving files or undoing your work. Containing a set of commands that are independent, this toolbar is actually customizable wherein you could change these icons to the ones you really need and frequently use. By tweaking the settings, you can even add commands to the Quick Access Toolbar that are not in the ribbon (like New, Open and Print).
7 0
2 years ago
Brake lights on freeways invite A: law enforcement B: panic C: sudden lane changing D: both B and C E: positive driving habits
Nuetrik [128]
I'am sorry i'am speak spanish

8 0
1 year ago
Which of the following is a true statement about cloud computing?
Veseljchak [2.6K]

Answer:

There are additional security risks associated with using cloud computing over local data storage.                    

Explanation:

Cloud computing: The term "cloud computing" is described as a process through which an individual tends to access and store various programs and data over the internet rather than his or her computers' "hard drive". However, the term "cloud" here refers to a specific metaphor associated with the internet.

Types:

1. Software-as-a-service or SaaS.

2. Platform-as-a-service or PaaS.

3. Infrastructure-as-a-service or IaaS.

In the question above, the very first option is correct as all other options mentioned over here are incorrect because they aren't related to cloud computing.

3 0
1 year ago
Other questions:
  • How did josh norman and mike keller provide coverage of katrina?
    9·2 answers
  • When should a technician record a system's baseline data?
    10·1 answer
  • _____ is the process of adjusting colors in an image.
    13·2 answers
  • Timing circuits are a crucial component of VLSI chips. Here’s a simple model of such a timing circuit. Consider a complete balan
    10·1 answer
  • A triangular number is a number that is the sum of the integers from 1 to some integer n. Thus 1 is a triangular number because
    11·1 answer
  • Print either "Fruit", "Drink", or "Unknown" (followed by a newline) depending on the value of userItem. Print "Unknown" (followe
    13·1 answer
  • Your employer, yPlum Corporation is manufacturing two types of products: Mirabelle smartphone, and Blackamber laptop. The compan
    14·1 answer
  • PLEASE HELP PROGRAMMING WILL GIVE BRAINLIEST
    6·1 answer
  • A mobile device user has tried to install a new app numerous times without success. She has closed all unused apps, disabled liv
    7·1 answer
  • Computers represent color by combining the sub-colors red, green, and blue (rgb). Each sub-color's value can range from 0 to 255
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!