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
zavuch27 [327]
4 years ago
6

Consider this data sequence: "3 11 5 5 5 2 4 6 6 7 3 -8". Any value that is the same as the immediately preceding value is consi

dered a consecutive duplicate. In this example, there are three such consecutive duplicates: the 2nd and 3rd 5s and the second 6. Note that the last 3 is not a consecutive duplicate because it was preceded by a 7. Write some code that uses a loop to read such a sequence of non-negative integers , terminated by a negative number. When the code finishes executing, the number of consecutive duplicates encountered is printed. In this case, 3 would be printed. Assume the availability of a variable, stdin, that references a Scanner object associated with standard input. That is, stdin = new Scanner(System.in); is given.
Computers and Technology
1 answer:
Darya [45]4 years ago
3 0

// Variable to keep track of array size

int length = 0;

// Array itself

int array[] = {};

// while loop will take input in the array until a negative number is entered

while(input>=0){

stdin = new Scanner(System.in);

array[length] = stdin;

length +=1;

}

// int variable to terminate while loop

int i =0;

// keep track of index of output array

int y =0;

while(arr[i] != length){

// making output array

int output[]={}; bool flag;

// put the element in out put array considering if it the desired one

output[y] = array [i];

// Now check if it was the desired?

for(int z=1;z<=length;z++){

if(array[i+z]!=output[y]){

 flag = true;

}

else

{

 output[y]=0;

 y+=1;

}

if(array[i+z+1]=output[y] && flag == true){

output[y] = array[i];

y+=1;

}

}

//output the array

for(int o=0;o<y;o++)

System.out.println(output[o];

You might be interested in
What type of devices are a keyboard and a mouse?
natulia [17]
They are technology devices
5 0
3 years ago
Click to review the online content. Then answer the question(s) below, using complete sentences. Scroll down to view additional
kumpel [21]

Explanation:

hope this help here is the answer

3 0
4 years ago
Can someone please help me
inn [45]

A pallet jack is a manually operated forklift

3 0
4 years ago
Write a Temperature class that will hold a temperature in Fahrenheit and provide methodsto get the temperature in Fahrenheit, Ce
julsineya [31]

Answer: Thermometer

Explanation:

5 0
4 years ago
In a ________ network, each node connected to the network communicates directly with every other node.
nlexa [21]
I am definitely sure that correct answer looks like this: In a <span>peer-to-peer </span>network, each node connected to the network communicates directly with every other node. Peer-to-peer or P2P network is a network in which every client connected to another client and they are depended on each other. When one of them has connection problems, another one gets them too.
5 0
3 years ago
Other questions:
  • Recursion is memory-intensive because ________. Select one: a. it requires large data values b. it must occur numerous times bef
    11·1 answer
  • What is syntax?
    6·1 answer
  • A manager in your company wants to standardize all mobile device applications across different operating systems. Some users hav
    10·1 answer
  • g c 24-hour time (also known in the U.S. as military time) is widely used around the world. Time is expressed as hours since mid
    7·1 answer
  • What is network and also how many types of network are there as well
    6·2 answers
  • HELP PLSSSSS!!! I WILL MARK BRAINLIEST FOR THE FIRST AND CORRECT ANSWER!!!
    14·2 answers
  • ......... defines the path of the movement for an object.
    12·1 answer
  • Who is responsible for developing the physical background for the characters by creating buildings, landscapes, and interiors?
    14·1 answer
  • A large number of consecutive IP addresses are available starting at 198.16.0.0. Suppose that four organizations, Able, Baker, C
    11·1 answer
  • Study the graph and answer the questions. The numbers on the left side of the graph are in thousands.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!