Compose a C++ function named getSpeed that uses a reference parameter variable named speed to accept an integer argument. The function should prompt the user to enter a number in the range of 20 through 70. The value entered by the user should be validated and stored in the parameter variable. Set the parameter variable to zero if the user enters a number outside the range of 20 through 70. void getSpeed (int &speed) { Cout << “Enter a number in the range between 20 and 70” << endl; Cin>>speed; If ( speed <=20 || speed >= 70) Speed = 0; }

Answers

Answer 1

// Making the function

void getSpeed(int &speed){

// initialize the variable to take input

int input =0;

cout << " Enter the Number in range of 20 through 70 : "<<;

cin>>input;

// validate the input

if(input>=20 && input<=70)

 speed = input;

else

 speed = 0;

}


Related Questions

An administrator has created a new custom object in a sandbox environment and now is ready to deploy in production. How can the administrator ensure that the field-level security that was tested and approved in the sandbox environment is maintained as part of the deployment? a) Create a change set that includes the custom object and all custom fields b) Create a change set that includes the custom object and all profiles c) Create a change set that includes the custom object, check the retain field-level security option d) Create a change set for the custom object; use Data Loader to transfer field-level security

Answers

Answer:

Option D

Explanation:

Option A is rejected because adding a custom object will cost both in memory and computation power. Consider that you have 1 million users, than there will be 1 million custom objects in the memory for checking the security which is not good.

Option B is not answer because again making a custom object will cost in memory and computation power.

Option C is not good because it also makes the custom object.

Option D is selected because change sets can be made which will not cost as much as the other options are costing. Also Data Loader can have come credentials defined in it which we can use to check if the user activities are according to the rules at each level.These days these data loader object technique is used because there will be static change sets for the class of users to check security.

_______________, such as BASIC, Python, Java, Prolog, and C , make the programming process easier by replacing unintelligible strings of 1s and 0s or cryptic assembly commands with understandable commands, such as PRINT and WRITE.

Answers

Answer:

High level Languages

Explanation:

High level languages are made so that the byte code, Assembly code that computers can understand should be converted into a higher level human understandable languages such as Python,C++. Also, remember that the compilers of these languages such as Visual studio ultimately converts the high level code into low level code ( Assembly code ) that computers can understand.

Assume that two int constants,FIRST_YEAR and LAST_YEAR have already been declared and initialized with year values (like 2009, 2014), along with a double variable oil that has been initialized with the number of barrels of oil consumed in Canada in the year given by FIRST_YEAR. Write some code that uses a while statement to print on a line by itself, each of the years from FIRST_YEAR to LAST_YEAR inclusive. On each line, after the year, separated by a colon and a space, print the new value amount of oil, taking into account that each year the oil consumed increases by 20%.

Answers

// While loop

while(FIRST_YEAR < LAST_YEAR)

{

cour<<"Year : " << First_YEAR << " Oil consumed is : " << oil <<"."<<endl;

FIRST_YEAR+=1;

// calculate the 20% increase

oil = oil + (oil *.20)

}

Other Questions
2. Which statement about the relationship between Richard the lionheart and Saladin is correct? Lucas debe terminar el trabajo antes de que su jefe (boss) (llegar). Question 2 with 1 blank Qu tenemos que hacer en caso de que (haber) una emergencia? Question 3 with 1 blank Ellos van a pintar su casa con tal de que (t) los (ayudar). Question 4 with 1 blank No puedo ir al museo a menos que Juan (venir) por m. Question 5 with 1 blank Alejandro siempre va a casa de Carmen sin que ella lo (invitar). Question 6 with 1 blank Tu madre te va a prestar dinero para que te (co An electric motor is to be supported by four identical mounts. Each mount can be treated as a linear prevent problems due required that the amplitude of motion should not exceed 0.1 mm per 1 N of unbalance force. The mass of the motor is 120 kg and the operating speed is 720 rpm Use the concept of transfer function to determine the required stiffhess coefficient of each mount. What is infix, prefix and postfixexpressions in data structures? Which best describes the Underground Railroad?A. a series of stops and safe houses for escaped slaves organized by the American Anti-slavery SocietyB. a loose network of people who helped slaves escape to the NorthC. a formal movement that freed slaves in daring raidsD. a series of passages leading north from the Deep South What are the requirement analysis for COREBANKING? f(x) = 8x^2 - 2x + 3g(x) = 12x^2 + 4x-3What is h(x) = f(x) g(x)?h(x) = 20x^2 + 2xh(x) = -4x^2 - 6xh(x) = -4x^2 - 6x + 6h(x) = -4x^2 + 2x Which sentence has an error between Comment tu t'appelles, Quelle age es-tu, Quand est ton anniversaire,Quelle heure est-il As a car increases velocity, does its kinetic energy or momentum increase faster? Explain. 2. Read the following sentence.The actress, known for her siren roles, wore a classic-looking gown with a beautiful train for the movie premiere.What does the word siren mean?A. dullB. excitingC. vainD. creative Upland has a population of 15,000, of whom 9,000 work 8 hours a day to produce real output of $342,000. Lowland has a population of 8,000, of whom 7,000 work 7 hours a day to produce real output of $171,500. A. Upland has higher productivity and higher real GDP per person than Lowland. B. Upland has higher productivity but lower real GDP per person than Lowland. C. Upland has lower productivity but higher real GDP per person than Lowland. D. Upland has lower productivity and lower real GDP per person than Lowland. An environmentalist wants to find out the fraction of oil tankers that have spills each month.Step 1 of 2:Suppose a sample of 474tankers is drawn. Of these ships, 318 did not have spills. Using the data, estimate the proportion of oil tankers that had spills. Enter your answer as a fraction or a decimal number rounded to three decimal places. what is the value of the discriminant of the quadratic equation -2x^2 -8x+8 and what does it value mean about the number about the number If x+3/3=y+2/3, then x/3= A) y/3B)y-1C)y/2D)y+1 Bergmanns rule:A)is based on the principle that heat is retained at the body surfaceB)concerns the relationship between climate and shape and size of appendagesC)state that bodies with increased mass or volume to surface area are optimal for cold climatesD)states that a linear body with long arms and legs is optimal for cold climates How must you react to a flashing yellow traffic light? Permeable rock strata or sediment that transmit groundwater freely are called ________. Open addressing can be implemented in several ways.TrueFalse What explorer first visited the u.S. River? HELP PLEASE???!!!!!!!What is the solution to the system of equations below?y=3/4x-12 and y=-4x-31A. (4, 15)B. (4, 12)C. (4, 9)D. (4, 47)