Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions 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]
expand button
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
Check Mark
Knowledge Booster
Background pattern image
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education