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
Alinara [238K]
4 years ago
7

python 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 i

s considered 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.
Computers and Technology
1 answer:
Vika [28.1K]4 years ago
7 0

int firstNumber,secondNumber = -1, duplicates = 0;

do {

cin >> firstNumber;

if ( secondNumber == -1) {

secondNumber = firstNumber;

}else {

if ( secondNumber == firstNumber )

duplicates++;

else

secondNumber = firstNumber;

}

} while(firstNumber > 0 );

cout << duplicates;

You might be interested in
Does anyone have any tips on how to begin a 10 page Capstone project paper? I've got to write a write a research paper on the ty
Stella [2.4K]

Answer:

first resherch what you will be doing on the job and maybe what training you will need and what school you will have to go to it might also help to include what pay you would get and how many hours you will do

Explanation:

sorry its not much but i hope this helps

8 0
2 years ago
Read 2 more answers
The processor has a five-stage pipeline F D O E M S; that is, instruction fetch, instruction decode, operand fetch, execute, mem
lawyer [7]

Answer:

a) Internal Forwarding is not used = 26 clock cycles

b)Internal Forwarding is used= 22 clock cycles

5 0
4 years ago
Select three nonrenewable types of energy.
trapecia [35]

Answer:

nuclear, coal,petroleum

6 0
3 years ago
Write a method called average that accepts two integer parameters and returns their average as a floating point value: Overload
kherson [118]

Answer:

   public static double average(int num1, int num2){

       return (num1+num2)/2;

   }

   public static double average(int num1, int num2, int num3, int num4){

       return (num1+num2+num3+num4)/2;

   }

Explanation:

  • In the first instance, the method average() accepts two parameters and returns their average
  • In the second instance the method accepts four parameters and returns their average
  • The concept of method overloading allows a program to have more than method with the the same name but with different parameters list like we find in this example
5 0
3 years ago
The ____________ is a wildcard character that is used to search for an unknown single character.
mafiozo [28]
Asteristik or as we see as (*)
5 0
3 years ago
Other questions:
  • Which of the following can you NOT apply for at any FLHSMV office? A. Certificate of title B. License plates C. Vehicle registra
    15·2 answers
  • What would make this comparison statement False? Complete with the appropriate relational operator. "G" _____= "G"
    10·1 answer
  • Janet has to create a webpage for a software company that should be accessible from both desktop computers and mobile devices. W
    12·1 answer
  • A TCP entity opens a connection and uses slow start. Approximately how many round-trip times are required before TCP can send N
    11·1 answer
  • Which of the following best describes Roblox?
    12·2 answers
  • Which network protocol is used to route IP addresses?<br>A. TCP<br>B. UDP<br>C. IP<br>D. ICMP
    15·1 answer
  • How do you add a picture to your questions? (on computer)
    10·1 answer
  • The part of a computer that provides access to the internet
    6·1 answer
  • A(n) __________ looks and acts just like a publicly accessible website and uses the same software, hardware, and networking tech
    7·1 answer
  • What symbol do we use to assign a value to a variable or constant in algorithms?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!