C++ coding
#include <stdlib.h>//atoi
#include <string.h>//strtok
#include <iostream>
#include <fstream>
#include <string>
and must be used
using namespace std;
The ultimate goal of this topic is to complete a simple score calculation system. Consider a gradetxt file that stores a set of (non- unique) teaching assistants for testing. Examples of content are as follows: 4;3; John;84;75;79; Mary:92:86:91; Lisa;50:70:61; Bob:90:99;93; The above example represents a total of 4 students, and each student's corresponding name has 3 test scores, and each score ranges from 0 to 100; the first student John's three test scores are 84, 75, and 79. The second student Mary's three test scores were 92, 86 and 91. The third student, Lisa, has three test scores of 50, 70, and 61. The fourth student, Bob, has three test scores of 90, 99, and 93. The detailed format of the grade.txt file is defined as follows. First, numbers are separated by semicolons. Among them, the first column () of the grade.txt file stores a total of 1 student and n exam results in the class. Then, each column starting from the second column of grade.txt file will have a number between 0 and 100 to represent 1 test score.
Write a program that can read the grade.txt file that conforms to the format. When the program executes the above assessment example, it will calculate the average score of the student (rounded to the nearest whole number) and pass or fail. (The average score above 60 is displayed as pass, otherwise it is displayed as fail) The average score is displayed on the execution screen from high to low. In addition, the content on the content screen will also be output to a FinalGrade.txt. (A FinalGrade.txt file with the following content can be found in the relative path after the program is executed) Bob's avg: 94 (pass) Mary's avg: 90 (pass) John's avg: 79 (pass) Lisa's avg: 60 (pass)
C++ coding #include //atoi #include //strtok #include #include #include
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am