Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Help !! Submit your answers to the following questions in a word processing document that is compatible with Microsoft Word. The name of the file
Help !!
Submit your answers to the following questions in a word processing document that is compatible with Microsoft Word. The name of the file you submit should be "XYLab6", where " X " and " Y" are your first and last initials. Questions (50 points): 1. Given the following C++ function header, compose a single C++ programming statement that calls the function, passing the literal value 21.0 as an argument, and assigning its return value to a correctly typed variable named result. double timesseven (double value) 2. Given the following C++ function header: double harmonic(int a, int b=12, int c=9, int d=6 ) and the following function call: double harmonicmean = harmonic (10,24); What will the value of the parameter variable named c be after the call is executed? 3. Compose a C++ function named timessix. The function should accept an integer (int) argument. When the function is called, it should display the product of the argument multiplied times six (6). 4. Compose a void C++ function named validatespeed that uses a reference parameter variable named speed to accept an integer argument. When called, the function should determine if the value of the parameter variable is in the range from 21 through 67. If the parameter variable is outside the range, set the parameter variable speed to 1. Otherwise, do nothing. Write the validatespeed function in such a way that it will work correctly in the following program: int number; cout "Enter a value for speed: "; cin number; validatespeed (number); if (number =1 ) cout "Invalid speed, In"; 5. Given the following prototype statement for a function that determines the maximum value between two given integer values: doublemaximum(doublea,doubleb); compose the prototype statement for an overloaded function that uses the same function name but determines the maximum value between two given integer values. Programming Exercise ( 50 points): Number of Drinks Write a program that estimates the number of alcoholic drinks (12 ounce beer, 5 ounce wine, or 1.5 ounces of distilled spirits) you can consume and remain within the legal limit of 0.08 per cent of Blood Alcohol Content (BAC). Your program will prompt the user to enter their weight in pounds and the percentage of alcohol in the beer they are drinking. Ordinary beers contain between 4% and 5% alcohol. (Represent percentage values such as 4% as 0.04, and 5% as 0.05.) Your program will use a function named numbrinks () that receives two arguments: - the user's weight (pounds) - the percentage of alcohol in the beer It will return an estimate of the number of drinks the user can have while remaining under the legal limit of Blood Alcohol Content. The formula you will use is a simplified version of the formula developed by Swedish physician E. M. P. Widmark. drinks=(0.08+0.015)weight/(127.5alcoho1); Where: drinks = Estimate of the number of drinks. weight = Weight in pounds. I alcohol = Percentage of alcohol in the beer. The program you write will repeatedly prompt the user to enter their weight and the percentage of alcohol in the beer. Use a while input validation loop to ensure that the value entered for weight is a positive number. Think about what controls your program should place on the values of alcohol percentage to make your program useful. A sentinel value of your choosing will terminate the program Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started