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 descriptions can be used for last,first,PR_ID and CID
faust18 [17]

Answer:

x r

Explanation:

this is the answer like it thank you

5 0
3 years ago
Which type of boot authentciation is more secure?
xeze [42]
The correct answer would b (C) because all the other ones are not on the list
7 0
3 years ago
What are the benefits of using presentations to organize and deliver information?
bearhunter [10]
Hello.

The benefits of using presentations to organize and deliver information are: it keeps things in order, keeps peoples attention longer, and it looks more professional.
4 0
3 years ago
Java 2D Drawing Application. The application will contain the following elements:
kenny6666 [7]

Answer:

sadness and depression is my answer

Explanation:

5 0
3 years ago
What is the purpose of the " + " in the code labeled // line 2 below ?
UkoKoshka [18]

Answer:

To illustrate addition operation

Explanation:

Given

The above code segment

Required

Determine the purpose of "+" in label line 2

In line 2, num1 = 3  and num2 = 2 in line 3.

sum = 2 + 3 = 5 in line 4

From the given code segment, the plus sign is used as a string literal (i.e. "+").

This means that, the print statement will output: <em>3 + 2 = 5</em>

The "+" is printed in between 3 and 2.

So, the purpose of the "+" is to show the function of the program and the function of the program is to illustrate an addition operation between two variables

7 0
3 years ago
Other questions:
  • Why is it important to match the latencies fo the older modules to the newer modules?
    14·1 answer
  • A professor is working with five teams in his marketing research class. He decides to experiment with path-goal theory in helpin
    11·1 answer
  • Tamara has $500 she is looking to save for a class trip. She wants to earn the most possible interest and will not need access t
    7·1 answer
  • The Gauss-Seidel method as an iterative technique often refers to an improved version of the Jacobi method, since the Gauss-Seid
    13·1 answer
  • (5 pt.) The name of a variable in the C programming language is a string that can contain uppercase letters, lowercase letters,
    15·1 answer
  • Had you guys go to prom by yourself or someone in your senior class
    5·2 answers
  • A web application that is designed as a single piece of software with multiple features that are fully integrated into the main
    9·1 answer
  • You are in charge of an event at work. You want to plan and schedule events and resourse. What type of software should you use?
    14·2 answers
  • What format should a cover letter be in?
    13·2 answers
  • Use the drop-down menus to complete statements about archiving and backing up data fileArchiving data files manages the size of
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!