4 Functions with Reference Parameters Use program MPH for Exercises 5. Program MPH reads two real numbers, miles and hours, and prints milesPerHour on the screen. Function GetData prompts the user for the appropriate values, reads them, and returns them to function main as reference parameters. // Program MPH reads miles and hours and prints miles // per hour. #include #include using namespace std; /* FILL IN the function prototype for GetData */ int main () float miles; float hours; float milesPerHour; cout << fixed << showpoint; /* FILL IN code to invoke function GetData */ milesPerHour = miles / hours; cout << setw(10) << miles << setw (10) << hours << setw (10) < milesPerHour << endl; return 0; /* FILL IN the function heading for GetData */ /* FILL IN code to prompt for miles and hours */ /* FILL IN code to read miles and hours */ Exercise 5. Fill in the missing code and compile and run your program three times using the following values and record the results. Miles Hours Miles per Hour 120.1 332.0 1250.0 2.2 5.5 20.0

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Can anyone help me these coding questions
## Functions with Reference Parameters

In this section, we explore the implementation of a C++ program that utilizes functions with reference parameters to compute and display miles per hour. The program, named `MPH`, reads two real numbers: `miles` and `hours`. It then calculates and outputs `milesPerHour` based on these inputs. A function named `GetData` is responsible for prompting users for the relevant values, processing the inputs, and returning them to the `main` function as reference parameters.

### Code Overview

```cpp
// Program MPH reads miles and hours and prints miles per hour.
#include <iostream>
#include <iomanip>
using namespace std;

/* FILL IN the function prototype for GetData */

int main() {
    float miles;
    float hours;
    float milesPerHour;
    cout << fixed << showpoint;

    /* FILL IN code to invoke function GetData */

    milesPerHour = miles / hours;
    cout << setw(10) << miles 
         << setw(10) << hours
         << setw(10) << milesPerHour << endl;
    return 0;
}

//***********************************************
/* FILL IN the function heading for GetData */
// {
    /* FILL IN code to prompt for miles and hours */
    /* FILL IN code to read miles and hours */
// }
```

### Exercise 5

The exercise requires filling in the missing components of the program, compiling, and running the program three times using the provided values. Results are to be recorded.

#### Values to Use:

| Miles | Hours | Miles per Hour |
|-------|-------|----------------|
| 120.1 | 2.2   |                |
| 332.0 | 5.5   |                |
| 1250.0| 20.0  |                |

### Instructions

1. **Function Prototype and Definition**: Implement the function prototype and definition for `GetData` to ensure that user prompts and data reading operations are correctly handled.

2. **Invoke GetData Function**: Modify the main function to call `GetData` and pass the necessary parameters by reference.

3. **Compile and Run**: Compile the program and run it using the provided data to verify correctness. Calculate `milesPerHour` and record the results for each set of inputs.

Through this exercise, learners will develop an understanding of how reference parameters work in C++ and how they can be effectively
Transcribed Image Text:## Functions with Reference Parameters In this section, we explore the implementation of a C++ program that utilizes functions with reference parameters to compute and display miles per hour. The program, named `MPH`, reads two real numbers: `miles` and `hours`. It then calculates and outputs `milesPerHour` based on these inputs. A function named `GetData` is responsible for prompting users for the relevant values, processing the inputs, and returning them to the `main` function as reference parameters. ### Code Overview ```cpp // Program MPH reads miles and hours and prints miles per hour. #include <iostream> #include <iomanip> using namespace std; /* FILL IN the function prototype for GetData */ int main() { float miles; float hours; float milesPerHour; cout << fixed << showpoint; /* FILL IN code to invoke function GetData */ milesPerHour = miles / hours; cout << setw(10) << miles << setw(10) << hours << setw(10) << milesPerHour << endl; return 0; } //*********************************************** /* FILL IN the function heading for GetData */ // { /* FILL IN code to prompt for miles and hours */ /* FILL IN code to read miles and hours */ // } ``` ### Exercise 5 The exercise requires filling in the missing components of the program, compiling, and running the program three times using the provided values. Results are to be recorded. #### Values to Use: | Miles | Hours | Miles per Hour | |-------|-------|----------------| | 120.1 | 2.2 | | | 332.0 | 5.5 | | | 1250.0| 20.0 | | ### Instructions 1. **Function Prototype and Definition**: Implement the function prototype and definition for `GetData` to ensure that user prompts and data reading operations are correctly handled. 2. **Invoke GetData Function**: Modify the main function to call `GetData` and pass the necessary parameters by reference. 3. **Compile and Run**: Compile the program and run it using the provided data to verify correctness. Calculate `milesPerHour` and record the results for each set of inputs. Through this exercise, learners will develop an understanding of how reference parameters work in C++ and how they can be effectively
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 4 images

Blurred answer
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education