diff options
author | msglm <msglm@techchud.xyz> | 2023-01-14 05:31:48 -0600 |
---|---|---|
committer | msglm <msglm@techchud.xyz> | 2023-01-14 05:31:48 -0600 |
commit | 9d53d8857eaa1c9405894a88ca75bc4657e42f35 (patch) | |
tree | eb1efc1d028b949dd83bb710c68be8eff58f26e7 /C++/studentScore | |
download | school-code-master.tar.gz school-code-master.tar.bz2 school-code-master.zip |
Diffstat (limited to 'C++/studentScore')
-rw-r--r-- | C++/studentScore/studentScore.cpp | 73 | ||||
-rw-r--r-- | C++/studentScore/studentScore.txt | 6 | ||||
-rw-r--r-- | C++/studentScore/testavg.out | 4 |
3 files changed, 83 insertions, 0 deletions
diff --git a/C++/studentScore/studentScore.cpp b/C++/studentScore/studentScore.cpp new file mode 100644 index 0000000..b40229a --- /dev/null +++ b/C++/studentScore/studentScore.cpp @@ -0,0 +1,73 @@ +// Name: msglm +// Date: +// Introduction: +// Description: + + +#include <iostream> +#include <string> +#include <fstream> +#include <iomanip> +using namespace std; + +// Named constants + +int main() { + + //Variable declaration + ifstream inFile; + ofstream outFile; + string name1, name2, name3; + double test1, test2, test3; + double test4, test5, test6; + double test7, test8, test9; + double average1, average2, average3; + + //Program title and description for the user + //cout << "Title: " << endl << "Description: " << endl; + + // User input + // Dealing with input/output files + inFile.open("studentScore.txt"); + outFile.open("testavg.out"); + + //Reading from the file + getline(inFile, name1); + inFile >> test1 >> test2 >> test3; + inFile.ignore(); + + getline(inFile, name2); + inFile >> test4 >> test5 >> test6; + inFile.ignore(); + + getline(inFile, name3); + inFile >> test7 >> test8 >> test9; + inFile.ignore(); + + // Calculations + average1 = (test1+test2+test3)/3.0; + average2 = (test4+test5+test6)/3.0; + average3 = (test7+test8+test9)/3.0; + + // Output to the screen + + outFile << fixed << showpoint << setprecision(2); + outFile << setw(17) << left << "Name: " << setw(8) << "Test 1" << setw(8) << "Test 2" << setw(8) << "Test 3" << setw(8) << "Average" << endl; + outFile << setw(17) << left << name1 << setw(8) << test1 << setw(8) << test2 << setw(8) << test3 << setw(8) << average1 << endl; + outFile << setw(17) << left << name2 << setw(8) << test4 << setw(8) << test5 << setw(8) << test6 << setw(8) << average2 << endl; + outFile << setw(17) << left << name3 << setw(8) << test7 << setw(8) << test8 << setw(8) << test9 << setw(8) << average3 << endl; + + inFile.close(); + outFile.close(); + + cout << "Please Check testavg.out file" << endl; + + return 0; +} + +/*This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + diff --git a/C++/studentScore/studentScore.txt b/C++/studentScore/studentScore.txt new file mode 100644 index 0000000..647019e --- /dev/null +++ b/C++/studentScore/studentScore.txt @@ -0,0 +1,6 @@ +Indira Dutta +67.2 58.54 98.3 +Anonymous Anonymous +30.4 90.4 75.4 +Jarvis Henderson +40.3 24.5 90.4 diff --git a/C++/studentScore/testavg.out b/C++/studentScore/testavg.out new file mode 100644 index 0000000..8624224 --- /dev/null +++ b/C++/studentScore/testavg.out @@ -0,0 +1,4 @@ +Name: Test 1 Test 2 Test 3 Average +Indira Dutta 67.20 58.54 98.30 74.68 +Anonymous Anonymous 30.40 90.40 75.40 65.40 +Jarvis Henderson 40.30 24.50 90.40 51.73 |