answer.
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]
2 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]2 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
A computer is a multipurpose device that accepts input, processes data, stores data, and produces output, all according to a ser
Bingel [31]

A computer is a multipurpose device that accepts input, processes data, stores data, and produces output, all according to a series of stored <u>instructions</u>. The <u>central</u> processing unit of most modern computers is a <u>microprocessor</u>. The instructions that tell a computer how to carry out a task are referred to as computer <u>programs</u>, which are distributed as software. Computers run three main types of software: <u>Application</u> software, system software, and development tools. An example of system software is a computer <u>operating</u> system, which is essentially the master controller for all the activities that a digital device performs. Digital devices are constructed using tiny electronic components that represent data bits as electrical signals. The system unit houses the system board, which contains several <u>integrated</u> circuits made from semiconducting materials. Computers come in three popular form factors: component, <u>clamshell</u> and slate. Many of today's digital devices operate on battery power supplied by <u>Lithium</u> ion batteries. Battery life and lifespan can be extended by following good battery management practices.

<u>Explanation</u>

A computer is a multipurpose device that accepts input, processes data, stores data, and produces output, all according to a series of stored instructions. Input is data or information typed, submitted, or transmitted into a computer. Processing data involves performing calculations, drawing graphs, modifying documents, and many more. Output is the result produced by a computer. Processing is handled by the computer’s CPU (Central Processing Unit) and the central processing unit of most modern computers is a microprocessor. A microprocessor executes and manages all logical instructions passed to it and performs tasks involved in computer processing. The instructions that tell a computer how to carry out a task are referred to as computer programs, which are distributed as software. A program is software or set of ordered operations on a computer that performs a particular task or function. A program is created and compiled into a language that the computer can comprehend and then distributed as software. Computers run three main types of software: Application software, system software, and development tools. Application software are programs that help a user carry out a task while a system software helps  the computer system to monitor itself in order to function effectively. On the other hand, development tools are used for creating applications, operating systems, Web sites, and utilities. Digital devices are constructed using tiny electronic components that represent data bits as electrical signals. The system unit houses the system board, which contains several integrated circuits made from semiconducting materials. The essence of digital electronics is the small circuit boards and integrated circuits you see when you open up a digital device. ICs are sets of electronic circuits engraved onto a thin slide of semiconducting material. Computers come in three popular form factors: component, clamshell and slate. Form factor in computer terms refers to the size and dimensions of then device. Clamshell devices have features characterized by a keyboard as the base and a screen on the hinged cover. Those devices configured in the slate form factor have a touchscreen that covers majority of the device’s surface. Many of today's digital devices operate on battery power supplied by Lithium ion batteries. Battery life and lifespan can be extended by following good battery management practices. Many of today's digital devices operate on battery power supplied by Lithium ion batteries. Battery life and lifespan can be extended by following good battery management practices.

7 0
2 years ago
There are no breakpoints in the "Access Customer Account" subpage however there is an error. What will happen if you choose to s
blsea [12.9K]

Answer:

Move to the breakpoint at "Get Customer Details" stage.

Explanation:

This question is incomplete, we need a diagram and four options to resolve this questions, I attached the diagram and the options.

- The process will work all stages in the "Access Customer Account" page until the error is thrown and then focus would move to the breakpoint at "Get Customer Details" stage.

- The process will work all stages in the "Access Customer Account" page until the error is thrown and then focus would move to the "Recover1" stage.

- The process will work all stages in the "Access Customer Account" page until the error is thrown and then focus would move to the stage containing the error on the "Access Customer Account" page.

- The process will work all stages in the "Access Customer Account" page until the error is thrown and then focus would move to the "Exception1" stage.

In this case, we are going to run an extra from subpage testing in <u>Process studio</u>. Process studio is a tool where we can test these processes.

The process always it's going to work all stages in the "Access Customer Account" we're going to receive an interruption when the error is activated, moving the focus to the Get Customer Details stage.

There is an error in the stage Access Customer Account, if we run the processes with the Go button, the focus should move into the Recover1 stage, and should show the error.

But in this particular example, we must use the STEP OUT BUTTON, What means this?

The process it's going be executed, but won't show any error or message, because we have used the STEP OUT BUTTON.

If we use the STEP OUT BUTTON, the process should end but in this case, we have a breakpoint in Get Customer Details stage, for that the focus and the process will end in Get Customer Details stage and not at the end or at the Recover1 stage.

8 0
1 year ago
What elements of SANS 20 you could leverage to reduce the TCP/IP vulnerabilities of your workstation
Vlada [557]

Answer:

- limitation and control of network ports, protocols and services.

- Continuous vulnerability assessment and remediation.

Explanation:

The TCP or transmission control protocol is a layer 4 protocol (transport), that reliably transports packets in sequential segments to an application in the destination computer, using the ip address and the port number of the application.

The ICMP sent during the TCP/ip activities, can render the network vulnerable to attacks. limitation and control of the network ports, protocols and services and continuous assessment would mitigate the vulnerability of the TCP/ip model.

5 0
1 year ago
Given sphereRadius and piVal, compute the volume of a sphere and assign to sphereVolume. Look up the equation online (e.g., http
fenix001 [56]

Answer:

  1. #include <stdio.h>
  2. int main()
  3. {
  4.    const double piVal = 3.14159;
  5.    double sphereVolume = 0.0;
  6.    double sphereRadius = 0.0;
  7.    
  8.    sphereRadius = 1.0;
  9.    sphereVolume = 4.0/ 3.0 * piVal * sphereRadius * sphereRadius * sphereRadius;
  10.    
  11.    
  12.    printf("Sphere volume: %lf\n", sphereVolume);
  13.    return 0;
  14. }

Explanation:

Firstly we can identify the formula to calculate volume of sphere which is

Volume = 4/3 \pi r^{3}

With this formula in mind, we can apply this formula to calculate the volume of sphere in Line 10. This is important to perform floating-point division 4.0/3.0 to ensure the resulting value is a floating value as well. Since we have been given piVal and sphereRadius, we can just multiply the result of floating-point division with piVal and sphereRadius and get the sphereVolume value.

At last, display the sphere volume using printf method (Line 13).

6 0
2 years ago
Assume there is a class AirConditioner that supports the following behaviors: turning the air conditioner on and off. The follow
Dafna11 [192]

Answer:

1)

officeAC = new AirConditioner();

officeAC.turnOn();

2)

officeAC = new AirConditioner();

officeAC.turnOn();

officeAC.setTemp(69);  

Explanation:

1)

In the first statement a new object of the class AirConditioner whose reference is assigned to the officeAC. new is a keyword which creates an object of the class.

Next statement uses the method turnOn(). Reference to the new object officeAC is used to invoke this method turnOn().

2) The first two statements works the same as in 1)

The last statement invokes a method setTemp() using the reference variable and passes the value 69 to this method to set the desired temperature.

6 0
1 year ago
Other questions:
  • What helps companies and organizations to target masses of people, provide 24/7 services, and deliver better marketing in a chea
    13·2 answers
  • In a spreadsheet, the instructions for carrying out calculations are called __________. recalculations formulas templates macros
    13·1 answer
  • Two technicians are discussing lung protection in the shop. Technician A says that respiratory-protection devices can prevent yo
    5·2 answers
  • Prompt: Which references and reference formats are you most likely to use? Why?<br><br><br> ED2020
    13·2 answers
  • Mike has never used a slide software before, but he needs to create a presentation by the end of the week. what recourse would b
    8·1 answer
  • Write a fragment of code that reads in strings from standard input, until end-of-file and prints to standard output the largest
    10·1 answer
  • Create a generic class Box with a type parameter that simulates drawing an item at random out of a box. This class could be used
    7·1 answer
  • ___________is used for drawing 3D objects in the field of Science and Engineering.
    12·2 answers
  • In order to avoid slipping in the shop, your footwear should ___________.
    10·1 answer
  • Accenture has put together a coalition of several ecosystem partners to implement the principles of blockchain and Multi-party S
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!