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
Mashutka [201]
3 years ago
8

Consider this data sequence: "fish bird reptile reptile bird bird bird mammal fish". There is a CONSECUTIVE REPETITION of length

3 (the three consecutive birds) and a CONSECUTIVE REPETITION of length 2 (the two reptiles). There are also several SINGLETONs of length 1 (a singleton fish, a singleton bird, a singleton mammal, and another singleton fish).Write some code that uses a loop to read in a sequence of words, terminated by the "xxxxx". The code assigns to t the number of CONSECUTIVE REPETITIONS that were read. (For example, in the above data sequence that value would be 2.) Assume that t has already been declared but not initialized . Assume that there will be at least one word before the terminating "xxxxx".
Computers and Technology
1 answer:
ioda3 years ago
8 0

Answer:

The code is given below. Follow the question and the code definitions for better understanding.

Explanation:

#include<iostream>

#include<string>

using namespace std;

int main(){

string pastWord="";

string currentWord,nextWord;

int n,t;

int singleton=0;

int consecutive=0;

cout<<"Enter words. ('xxxxx' to exit):\n";

cin>>nextWord;

do{

currentWord=nextWord;

cin>>nextWord;

if ( (currentWord!=pastWord)&&(currentWord!=nextWord) )

singleton++;

else if((currentWord==pastWord)&&(currentWord!=nextWord))

consecutive++;

pastWord=currentWord;

}while(nextWord!="xxxxx");

n=singleton;

t=consecutive;

cout<<"There were "<<n<<" singletons and "<<t<<" consecutive repetitions.";

cin.get();

return 0;

}

You might be interested in
You can invoke or call a method from another program or method. When methods must share data, you can pass the data into and ret
san4es73 [151]

Answer:

1. You can invoke or call a method from another program or method: TRUE

2. When methods must share data, you can pass the data into and return the data out of methods: TRUE

3. A method could be called using any numeric value as an argument, whether it is a variable, a named constant, or a literal constant: TRUE

Explanation:

4 0
3 years ago
A persons decision to take action without being asked is
Nimfa-mama [501]

Answer:

Initiative

Explanation:

Initiative: the power or opportunity to act or take charge before others do.

5 0
3 years ago
How do I write this code in java? input "Enter Your Age to Order a Beer"
Klio2033 [76]

Answer:

i dont know sorry but answer above lol

Explanation:

5 0
3 years ago
A site has been issued the IP address of 192. 168. 10. 0/24. The largest network contained 25 hosts and was given the lowest num
dimulka [17.4K]

Answer:

Explanation: The first thing to calculate is what IP addresses are used by the largest LAN. Because the LAN has 100 hosts, 7 bits must be left for host bits.

Explanation:

Explanation: The first thing to calculate is what IP addresses are used by the largest LAN. Because the LAN has 100 hosts, 7 bits must be left for host bits.

4 0
1 year ago
You are troubleshooting a mobile device that will not pair with a Bluetooth headset. The device was functioning properly with th
bulgar [2K]

Answer:

B. Replace the Bluetooth headset with a new pair.

Explanation:

Since all other mobile devices, after receiving the "corporate-wide" OS update, aren't having issues with pairing with Bluetooth headsets, we can safely conclude that the OS update isn't the issue.

To find out if the Bluetooth headset is not the culprit, we can try to pair the mobile device with a different headset. If it pairs correctly, then we can conclude that the old Bluetooth headset might have a fault, or it might need to be disconnected/forget from the device and paired gain.

7 0
3 years ago
Other questions:
  • A(n) ____ backup only archives the files that have been modified since the last backup.
    11·1 answer
  • When you sort a cell range using a to z or z to a, what is rearranged?
    5·1 answer
  • 2. What are the pros and cons of Toyota structure?
    13·1 answer
  • Assign jsonData with the parsed value of the stringData variable. Then, assign 29 to the points property in jsonData and assign
    13·1 answer
  • Consider the following constructor for an immutable matrix ADT:
    8·1 answer
  • The Software Engineering Code of Ethics and Professional Practice was developed by Select one: a. Computer Professionals for Soc
    7·1 answer
  • Each pixel includes 3 colors; Red, Green and Blue. Each color uses 8 bits to store it's intensity. How many Bytes are needed for
    12·1 answer
  • Whate is function of northe bridge<br>​
    12·1 answer
  • Why would you browse by entering a URL rather than use a link in a Web page
    15·1 answer
  • Each of the flowchart segments in Figure 3-24 is unstructured. Redraw each segment so that it does the same processes under the
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!