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
saul85
1 month 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:
oksian1 [797]1 month ago
7 0

int currentNumber,previousNumber = -1, countDuplicates = 0;

do {

cin >> currentNumber;

if ( previousNumber == -1) {

previousNumber = currentNumber;

}else {

if ( previousNumber == currentNumber )

countDuplicates++;

else

previousNumber = currentNumber;

}

} while(currentNumber > 0 );

cout << countDuplicates;

You might be interested in
if you had two proxy servers located in the same room, what use could you make of them? nothing create a hub sell one of the ser
Harlamova29_29 [932]
Establish a free wifi service
6 0
1 month ago
Read 2 more answers
A user calls the help desk and reports that the workstation, when powering up, displays error messages about an invalid system d
ivann1987 [930]

Answer:

Option (A) is the correct choice.

Explanation:

The situation describes an invalid boot disk error occurring during startup, indicating that the system fails to recognize the hard disk necessary for booting.

MBR / GPT is the partition layout that holds the essential code for system startup. Occasionally, the partition files that contain this code may become corrupt, causing an invalid boot disk error during the boot process.

Therefore, the most fitting answer is option (A).

The remaining choices are incorrect for these reasons:

  • If the boot system malfunctions, it cannot produce an invalid boot disk error.
  • If the files of the operating system are corrupted, the error will pertain to missing files.
  • A device driver cannot influence the system's booting process.
5 0
1 month ago
The budget process which emphasizes the achievement of goals and competition between alternatives is:
Rzqust [894]

The question offers several choices;


<span>A) </span>Incremental budgeting.
B) Performance budgeting.
C) Program budgeting.
D) Target based budgeting.


I'd argue that D is the correct option; Target based budgeting.


Target based budgeting centers on achieving objectives and competing alternatives. This budgeting approach uses pricing as a strategic tool to influence sales outcomes. It involves market research to determine the precise selling price of a product.






4 0
1 month ago
A method countDigits(int num) of class Digits returns the remainder when the input argument num(num &gt; 0) is divided by the nu
ivann1987 [930]

Answer:

#include <iostream>

using namespace std;

class Digits

{

   public:

   int num;

   int read()       //method to read num from user

   {

       cout<<"Enter number(>0)\n";

       cin>>num;

       return num;

   }

   int digit_count(int num)  //method to count number of digits of num

   {

       int count=0;

       while(num>0)    //loop till num>0

       {

           num/=10;

           count++;   //counter which counts number of digits

       }

       return count;

   }

   int countDigits(int num)   //method to return remainder

   {

       int c=digit_count(num); //calls method inside method

       return num%c;  

   }

};

int main()

{

   Digits d;    //object of class Digits is created

   int number=d.read();   //num is read from user

   cout<<"\nRemainder is: "<<d.countDigits(number);  //used to find remainder

   return 0;

}

Output:

Enter number(>0)

343

Remainder is: 1

Explanation:

The program has a logical error that needs rectification. A correctly structured program calculates the remainder when a number is divided by the count of its digits. A class named Digits is created, consisting of the public variable 'num' and methods for reading input, counting digits, and calculating the remainder.

  • read() - This function asks the user to enter the value for 'num' and returns it.
  • digit_count() - This function accepts an integer and counts how many digits it has, incrementing a counter until 'num' is less than or equal to 0. It ultimately returns the digit count.
  • countDigits() - This function takes an integer and delivers the remainder from dividing that number by its digit count. The digit count is computed using the 'digit_count()' method.

Finally, in the main function, a Digits object is instantiated, and its methods are utilized to produce an output.

7 0
1 month ago
On the seventh day of the iteration, the team realizes that they will not complete 5 of the 13 stories. the product owner says s
8_murik_8 [892]

Answer:

First, the team should apologize to the product owner for not meeting the deadline with the necessary responsibility and commitment.

Next, having finished 8 stories, they should review and correct any defects in those stories before sending them to her.

When the product owner reviews and approves the stories, she will likely discuss the remaining stories with the team.

6 0
1 month ago
Other questions:
  • print_pattern() prints 5 characters. Call print_pattern() twice to print 10 characters. Example output: ***** ***** in python
    7·1 answer
  • To reduce costs and the environmental impact of commuting, your company decides to close a number of offices and to provide supp
    14·1 answer
  • How to code 2.9.5: Four colored triangles {Code HS}
    10·1 answer
  • Imagine you were using some of our pixelation tools to create an image and you posted it online for your friends to see - but, a
    11·1 answer
  • Which decimal value (base 10) is equal to the binary number 1012?
    5·1 answer
  • Write an if-else statement to describe an integer. Print "Positive even number" if isEven and is Positive are both true. Print "
    14·1 answer
  • Define a method calcPyramidVolume with double data type parameters baseLength, baseWidth, and pyramidHeight, that returns as a d
    8·1 answer
  • Suppose we are sorting an array of eight integers using quicksort, and we have just finished the first partitioning with the arr
    6·1 answer
  • You are given a string of n characters s[1 : : : n], which you believe to be a corrupted text document in which all punctuation
    12·1 answer
  • Tanya wants to include a video with all its controls on her web page. The dimensions of the video are as follows:
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!