Write a program that prints a menu of choices:

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Question
100%

C++

### Programming Fundamentals: LAB - File Statistics

This exercise guides you through creating a program that interacts with a file to perform specific statistical operations. The program displays a menu of choices to the user as follows:

- **L** -> Find the lowest value in a file
- **H** -> Find the highest value in a file
- **A** -> Find the average value in a file
- **Q** -> Quit

#### Instructions:

1. **Menu Selection:**
   - If the user selects any option other than 'Quit', the program will prompt for a file name.
   
2. **File Processing:**
   - The program will read the file and compute the required statistic: highest, lowest, or average value.
   - It will then display the result with messages:
     - `Highest value is 0`
     - `Lowest value is 0`
     - `Average value is 0`

3. **Error Handling:**
   - If the file cannot be opened or is empty, it displays:
     - `File empty or could not open file`
   
4. **Program Termination:**
   - Upon selecting 'Quit', the program outputs “Exiting” and ends.

#### Additional Requirements:

- **No Arrays:** You are not allowed to use arrays in your implementation.
- **Implement Functions:**
  - These functions will handle file operations and calculations:
    - `bool averageFromFile(string filename, double& value);`
    - `bool lowestFromFile(string filename, double& value);`
    - `bool highestFromFile(string filename, double& value);`
  - Each function returns a `bool` indicating success. If successful and the file is not empty, the function computes and returns the required value using the reference parameter. If failed or empty, no value is returned.

Ensure you follow these guidelines and implement each required function to avoid losing points on this task.
Transcribed Image Text:### Programming Fundamentals: LAB - File Statistics This exercise guides you through creating a program that interacts with a file to perform specific statistical operations. The program displays a menu of choices to the user as follows: - **L** -> Find the lowest value in a file - **H** -> Find the highest value in a file - **A** -> Find the average value in a file - **Q** -> Quit #### Instructions: 1. **Menu Selection:** - If the user selects any option other than 'Quit', the program will prompt for a file name. 2. **File Processing:** - The program will read the file and compute the required statistic: highest, lowest, or average value. - It will then display the result with messages: - `Highest value is 0` - `Lowest value is 0` - `Average value is 0` 3. **Error Handling:** - If the file cannot be opened or is empty, it displays: - `File empty or could not open file` 4. **Program Termination:** - Upon selecting 'Quit', the program outputs “Exiting” and ends. #### Additional Requirements: - **No Arrays:** You are not allowed to use arrays in your implementation. - **Implement Functions:** - These functions will handle file operations and calculations: - `bool averageFromFile(string filename, double& value);` - `bool lowestFromFile(string filename, double& value);` - `bool highestFromFile(string filename, double& value);` - Each function returns a `bool` indicating success. If successful and the file is not empty, the function computes and returns the required value using the reference parameter. If failed or empty, no value is returned. Ensure you follow these guidelines and implement each required function to avoid losing points on this task.
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY