How do I use the void function to create a calculation that will work inside of a file? The attached picture is what I have so far, and I cannot get the function I created outside of the main program to work inside the program.
How do I use the void function to create a calculation that will work inside of a file? The attached picture is what I have so far, and I cannot get the function I created outside of the main program to work inside the program.
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...
Related questions
Question
How do I use the void function to create a calculation that will work inside of a file? The attached picture is what I have so far, and I cannot get the function I created outside of the main

Transcribed Image Text:This code appears to be a C++ program designed for managing student grades. It performs tasks such as calculating grade percentages and printing comments based on those grades. Below is a detailed explanation:
### Function Definitions
1. **`void comment(int tper)`**
- **Purpose**: Outputs a comment based on the grade obtained.
- **Logic**:
- `tper >= 90`: Prints "Excellent".
- `tper >= 80`: Prints "Well Done".
- `tper >= 70`: Prints "Good".
- `tper >= 60`: Prints "Need Improvement".
- `tper < 60`: Prints "Fail".
2. **`void avg(int score, int tposs)`**
- **Purpose**: Calculates the test score percentage.
- **Logic**:
- `per = score / tposs`: Determines the proportion of points scored.
- `tper = per * 100`: Converts the proportion to a percentage.
3. **`void lname(string lastname)`**
- **Purpose**: Outputs the last name of the student.
- **Logic**: Simply prints `lastname`.
### Main Function
1. **Initialization**:
- `cout << "" << endl << endl`: Placeholder for user to substitute their name and lab number.
2. **Variable Declarations**:
- `per`: Test score percentage.
- `tper`: Total percentage.
- `tposs`: Total possible points.
- `score`: Points scored.
- `lname`: Student's last name.
3. **Program Logic**:
- Opens a file named "TestScores.txt".
- If the file successfully opens, it reads data in the format of `lastname`, `score`, and `tposs`.
- For each student record:
- Calls `lname` to print the last name.
- Calls `avg` to calculate the average.
- Calls `comment` to print a comment about the grade.
### Note
- Modify the `cout` statement at the beginning of `main()` to include your name and lab number for personal reference.
- Ensure that the file "TestScores.txt" is accessible and properly formatted as expected by the program.
This code is useful for educators or students to automate the process of evaluating and commenting on students’ performance based on their scores.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps

Recommended textbooks for you

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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

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
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY