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 variable is assigned a value on line 328 of a program. Which of the following must be true in order for the variable to work?
Ivanshal [37]

Answer:

the answer is A

Explanation:

I just did this

3 0
3 years ago
Read 2 more answers
Characteristics of at-risk drivers
Firlakuza [10]
An at-risk driver is someone who is recklessly driving. an at-risk driver is a driver who is driving at a very high rate of speed. an at-risk driver is a driver who is someone who is driving in dangerous way as in no seatbelt or being distracted. 
4 0
3 years ago
Read 2 more answers
Select the correct answer.
Mekhanik [1.2K]
The best answer is A
5 0
3 years ago
Read 2 more answers
Your isp connects to the core routers of the internet via a _____. cable mode spine backbone satellite
melisa1 [442]

fairly certain its backbone

5 0
4 years ago
You can declare new classes as needed; this is one reason java is known as a(n) ________ language.
____ [38]
You can declare new classes as needed : this is one reason java is known as a extensible language.
8 0
3 years ago
Read 2 more answers
Other questions:
  • The use of computer and special software packages to create and edit documents
    11·1 answer
  • Create a short document titled "Guide to web searches" that Sergio can give to users of the facility he supervises. The document
    7·1 answer
  • . Does Zuckerberg believe in the thought that “the endpoint is when you sell the
    15·1 answer
  • Linda is training to become a certified network design expert and consultant. While researching about the process of cellular ra
    12·1 answer
  • What is difference between rand() and srand() ?
    11·1 answer
  • . The NFiPA 704 system uses a numerical value between _____ and _____ to indicate the level of hazard for that particular chemic
    7·1 answer
  • Need answer ASAP!!!!!
    6·1 answer
  • In a conditional statement, the______ symbol is used to separate a test expression from the expression to be processed if the te
    10·1 answer
  • I just logged onto brainly and all my questions were deleted and i lost 2 brainliest. What has brainly done to my account I also
    6·2 answers
  • which of the following is a scenario in which an it support technician would most likely be required to implement the alternate
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!