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
Nezavi [6.7K]
4 years ago
13

Write a statement that adds 1 to the variable reverseDrivers if the variable speed is less than 0,adds 1 to the variable parkedD

rivers if the variable speed is less than 1,adds 1 to the variable slowDrivers if the variable speed is less than 40,adds 1 to the variable safeDrivers if the variable speed is less than or equal to 65, and otherwise adds 1 to the variable speeders.
Computers and Technology
1 answer:
ch4aika [34]4 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.

OUTPUT

slowDrivers

You might be interested in
A spreadsheet can be filtered only by one column at a time? <br> true or false
Keith_Richards [23]
False. You can filter by multiple columns.
6 0
4 years ago
Read 2 more answers
What must be done before using ArrayLists?<br><br> (This is Java Programming btw)
Viktor [21]

Answer:

to create an ArrayList , you declare an Arraylist variable and call the ArrayList constructor to instantiate and ArrayList object and assign it to the variable

5 0
3 years ago
Using the flowchart diagram, identify the decision point of this solution. Identify vendors. Calculate amount due. Determine dat
andreev551 [17]

Answer:

answer is "is there an early pay discount"

Explanation:

3 0
4 years ago
Read 2 more answers
________ is a remote access client/server protocol that provides authentication and authorization capabilities to users who are
iren [92.7K]

Answer:

Correct answer is (4)

Explanation:

Terminal Access Controller Access Control System

4 0
3 years ago
How do i get my laptop to connect to wifi?
SashulF [63]
What type of computer do you have
3 0
3 years ago
Other questions:
  • Why were the spices in Asia so expensive when sold in Europe?
    11·2 answers
  • Consider an SRS for a system to manage grades at a typical University:
    14·1 answer
  • Keep getting the message i failed to sign in to email on my phone but i can open my email. whats going on?
    10·2 answers
  • How a hard drive works
    8·1 answer
  • How does form get its power natural gas
    14·1 answer
  • A network technician is designing a network for a small company. The network technician needs to implement an email server and w
    12·1 answer
  • if ur parent gets mad at u and says something then u say something, why do they say "stop back talking'' if ur just starting a c
    7·2 answers
  • Write a program which will enter information relating to a speeding violation and then compute the amount of the speeding ticket
    14·1 answer
  • Como se juega robótica de cokitos
    13·1 answer
  • What happens when you run a program in Python? ​
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!