C++ coding
use the ones here
#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.
Q3 write a program to integrate the first two questions. When starting to execute, it will read the grade.txt that matches the format, and then three options will be displayed on the screen for the user to choose. Note that the averages used in this question are all Round to an integer using the first decimal place. 1. Show a student's grades from the highest to the lowest and the associated avg. 2. Show the avg. for each student from the highest to the lowest 3. Exit and output a final report Choose an option (1-3): The program will continue to be executed until the user presses 3, and the teaching assistant will not measure numbers other than 1-3, so there is no need for fool-proofing here. An example of a program execution test is as follows. The teaching assistant's test example will be executed in the following order after the program is compiled: 1. Show a student's grades from the highest to the lowest and the associated avg. 2. Show the avg. for each student from the highest to the lowest 3. Exit and output a final report Choose an option (1-3):1 Please type a name: Mary 92:91:86: Avg: 90 1. Show a student's grades from the highest to the lowest and the associated avg. 2. Show the avg. for each student from the highest to the lowest 3. Exit and output a final report Choose an option (1-3):2 Bob's avg: 94 (pass) Mary's avg: 90 (pass) John's avg: 79 (pass) Lisa's avg: 60 (pass)
1. Show a student's grades from the highest to the lowest and the associated avg. 2. Show the avg. for each student from the highest to the lowest 3. Exit and output a final report Choose an option (1-3):3 Bob's avg: 94 (pass) Mary's avg: 90 (pass) John's avg: 79 (pass) Lisa's avg: 60 (pass) The above avg. grades are shown in the FinalGrade.txt file. The program is terminated.
C++ coding use the ones here #include //atoi #include //strtok #include #include
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am