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
almond37 [142]
3 years ago
9

Write a statement that increments (adds 1 to) one and only one of these five variables: reverseDrivers parkedDrivers slowDrivers

safeDrivers speeders. The variable speed determines which of the five is incremented as follows: The statement increments reverseDrivers if speed is less than 0, increments parkedDrivers if speed is less than 1, increments slowDrivers if speed is less than 40, increments safeDrivers if speed is less than or equal to 65, and otherwise increments speeders.
Computers and Technology
1 answer:
MariettaO [177]3 years ago
3 0

Answer:

The c++ coding for this scenario is given below.

if( speed < 0 )

           reverseDrivers = reverseDrivers + 1;

   else if( speed >= 0 && speed < 1 )

           parkedDrivers = parkedDrivers + 1;

   else if( speed >= 1 && speed < 40 )

           slowDrivers = slowDrivers + 1;

   else if( speed >= 40 && speed < 65 )

          safeDrivers = safeDrivers + 1;

   else

     speeders = speeders + 1;

Explanation:

First, five integer variables are declared and initialized.

int reverseDrivers = 0, parkedDrivers = 0, slowDrivers = 0, safeDrivers = 0, speeders = 0;

All the above variables need to be incremented by 1 based on the given condition, hence, these should have some original value.

Another variable speed of data type integer is declared.

int speed;

The variable speed is initialized to any value. User input is not taken for speed since it is not mentioned in the question.

Based on the value of the variable speed, one of the five variables, declared in the beginning, is incremented by 1.

The c++ program to implement the above scenario is as follows.

#include <iostream>

using namespace std;

int main() {

   int reverseDrivers = 0, parkedDrivers = 0, slowDrivers = 0, safeDrivers = 0, speeders = 0;

   int speed = 34;

   

   if( speed < 0 )

   {

       reverseDrivers = reverseDrivers + 1;

       cout<<" reverseDrivers " <<endl;

   }

   else if( speed >= 0 && speed < 1 )

   {

       parkedDrivers = parkedDrivers + 1;

      cout<<" parkedDrivers "<<endl;

   }

   else if( speed >= 1 && speed < 40 )

   {

       slowDrivers = slowDrivers + 1;

      cout<<" slowDrivers "<<endl;

   }

   else if( speed >= 40 && speed < 65 )

   {

       safeDrivers = safeDrivers + 1;

       cout<<" safeDrivers "<<endl;

   }

   else

   {

       speeders = speeders + 1;

       cout<<" speeders "<<endl;

   }

return 0;

}

The program only outputs the variable which is incremented based on the value of the variable speed.

You might be interested in
Which technology is predominately used for contactless payment systems?
kompoz [17]
The correct answer for this question is this one: "a. wireless local area network (WLAN)."

<span>The technology that is predominately used for contactless payment systems is called the </span><u>wireless local area network (WLAN)</u><u />. It is even used now a days.
Hope this helps answer your question and have a nice day ahead.
7 0
3 years ago
Read the excerpt from Act 111, scene iii of Romeo and Juliet. Which is the best paraphrase of this dialogue
Rufina [12.5K]
I think that D is the answer
8 0
3 years ago
What does a production proposal provide ?
aliina [53]

Answer:

information about the cast and crew

Explanation:

3 0
3 years ago
Read 2 more answers
Write a method that prints on the screen a message stating whether 2 circles touch each other, do not touch each other or inters
beks73 [17]

Answer:

The method is as follows:

public static void checkIntersection(double x1, double y1, double r1, double x2, double y2, double r2){

    double d = Math.sqrt(Math.pow((x1 - x2),2) + Math.pow((y1 - y2),2));

    if(d == r1 + r2){

        System.out.print("The circles touch each other");     }

    else if(d > r1 + r2){

        System.out.print("The circles do not touch each other");     }

    else{

        System.out.print("The circles intersect");     }

}

Explanation:

This defines the method

public static void checkIntersection(double x1, double y1, double r1, double x2, double y2, double r2){

This calculate the distance

    double d = Math.sqrt(Math.pow((x1 - x2),2) + Math.pow((y1 - y2),2));

If the distance equals the sum of both radii, then the circles touch one another

<em>     if(d == r1 + r2){</em>

<em>         System.out.print("The circles touch each other");     }</em>

If the distance is greater than the sum of both radii, then the circles do not touch one another

<em>    else if(d > r1 + r2){</em>

<em>         System.out.print("The circles do not touch each other");     }</em>

If the distance is less than the sum of both radii, then the circles intersect

<em>    else{</em>

<em>         System.out.print("The circles intersect");     }</em>

}

6 0
3 years ago
Some files appear dimmed in one of the default folders on your computer. What would be the best course of action?
Wittaler [7]
It appears that they might be labeled "Hidden" in the properties of that file. Right Click on Properties and Uncheckmark Hidden<span />
7 0
3 years ago
Other questions:
  • Which of the following is NOT one of the most important elements when designing a website?
    8·2 answers
  • Write a Python function merge_dict that takes two dictionaries(d1, d2) as parameters, and returns a modified dictionary(d1) cons
    5·1 answer
  • Which one is not among standard creation committee?
    9·1 answer
  • A snail goes up A feet during the day and falls B feet at night. How long does it take him to go up H feet? Given three integer
    8·1 answer
  • You are a disgruntled employee with a master’s degree in computer sciences who was recently laid off from a major technology com
    11·1 answer
  • _____ creates a border or space that separates information.
    14·1 answer
  • The number of pixels displayed on the screen is known as ________.
    13·1 answer
  • What is a example of blockchain
    8·1 answer
  • Multiple choice:
    12·2 answers
  • 2. Released in 1992, Street Fighter II, the revolutionary fighting game, was developed by which company?
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!