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]
3 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]3 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
WRITE A PROGRAM TO CALCULATE SIMPLE INTEREST
Alchen [17]

The simple interset program is a sequential program, and does not require loops and conditions

The simple interset program in Python, where comments are used to explain each line is as follows:

#This gets input for the principal amount

P = int(input("P = "))

#This gets input for the rate

R = int(input("R = "))

#This gets input for the number of years

N = int(input("N = "))

#This calculates the simple interest

I = P * R * T * 0.01

#This prints the simple interest

print("Simple Interest =",I)

Read more about simple interest at:

brainly.com/question/2294792

7 0
2 years ago
A friend of yours started her own dog walking business. At first she only had a couple customers, and she used Word to create al
GaryK [48]
Hire more people to help type her documents, or make Batch invoices
4 0
3 years ago
State the major different between fours types of computers
Igoryamba

Answer:

1. Supercomputers

Supercomputers are very expensive and very fast. They are the most powerful computers we have in the world.

Supercomputers are optimized to execute only a small number of programs. This makes it possible for them to execute these few programs at a very high speed. Due to their inhibiting cost, they are used in high-end places like in scientific research centers. The supercomputer consists of thousands of processors, allowing it to clock in at very high speeds measured by petaflops.

These computer types are also very large in size due to the numerous parts and components involved in their design.

A good example of a supercomputer is Tianhe-2, which is located in the National Supercomputer Center in Guangzhou, China. It features 3.12 million cores, allowing it to run at speeds of 33.86 petaflops.

2. Mainframe Computers

These are large and expensive computers that are capable of supporting thousands of users simultaneously. They are mostly used by governments and large organizations for bulk data processing, critical applications, and transaction processing. They are ranked below supercomputers.

3. Minicomputers

Minicomputers are mid-sized computers. In terms of size and power, they are ranked below mainframes. A minicomputer is a multiprocessing system capable of supporting from 4 to about 200 users simultaneously.

The use of the term minicomputer has diminished since the introduction of microprocessors. These machines are now more commonly called midrange computers.

4. Microcomputers

A microcomputer, also known as a personal computer, is designed to be used by one user at a time. The term microcomputer relates to the microprocessor that is used for the purpose of processing data and instruction codes. These are the most common computer types since they are not very expensive

8 0
2 years ago
Long-term memory used by the computer:
Fynjy0 [20]
The long term memory used by the computer is called “RAM”
6 0
2 years ago
Read 2 more answers
The function below tries to create a list of integers by reading them from a file. The file is expected to have a single integer
Setler [38]

Answer:

Check the explanation

Explanation:

def get_list_of_integers_from_file(filename):

int_list=[]

for line in open(filename).readlines():

try:

int_list.append(int(line))

except:

continue

return int_list

print(get_list_of_integers_from_file('file.txt'))

 

File.txt:

Kindly check the output below.

4 0
3 years ago
Other questions:
  • The main thing that adjusting the aperture controls when taking an image is?
    15·1 answer
  • You can join tables by using a condition in the ____ clause.​
    7·1 answer
  • A mobile device has stopped receiving automatic OS updates that until recently were pushed to the device.
    7·2 answers
  • Which tool is used to view stars in galaxies far from the Milky Way?
    10·1 answer
  • An online service allows users to integrate their phonebook with their social media profiles and stores it on the cloud. The pho
    12·1 answer
  • What is a single-user computer?
    8·1 answer
  • Which tab on the Chart Tools Contextual tab will contain commands that are used to change the style of charts and to edit chart
    12·2 answers
  • Write a C++ function using recursion that returns the Greatest Common Divisor of two integers. The greatest common divisor (gcd)
    14·1 answer
  • Function of dobji dzong​
    14·1 answer
  • How to set Campaign goals?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!