SlideShare a Scribd company logo
1 of 18
Download to read offline
#include "stdafx.h"
#include
#include
#include
#include
#include
using namespace std;
struct StudentData
{
int studentID;
string first_name;
string last_name;
int exam1;
int exam2;
int exam3;
int total;
char ch;
};
const int SIZE = 9;
const int INFO = 4;
// Function prototypes
void openInputFile(ifstream &, string);
void getTotal(StudentData[]);
void getGrade(StudentData[]);
void calcLowest(StudentData[], int &, int &, int &, int &, int[]);
void calcHighest(StudentData[], int &, int &, int &, int &, int[]);
void getAverage(StudentData[], int, double &, double &, double &, double &, double[]);
void getStd(StudentData[], double &, double &, double &, double &, double &, double &,
double &, double &, double[]);
void print(StudentData[], int[], int[], double[], double[]);
void sort(StudentData[]);
int main()
{
// Variables
StudentData arr[SIZE];
int lowest1, lowest2, lowest3, lowest4; // Stores lowest exam scores
int highest1, highest2, highest3, highest4; // Holds highest exam scores
double average1 = 0, average2 = 0, average3 = 0, average4 = 0; // Represents average of each
exam
double std1 = 0, std2 = 0, std3 = 0, std4 = 0; // Holds standard deviation for Exams 1-3 and
Total
int lowest[INFO] = {};
int highest[INFO] = {};
double average[INFO] = {};
double standardDeviation[INFO] = {};
ifstream inFile;
string inFileName = "C:UsersLisaDesktopscores.txt";
// Call function to read data in file
openInputFile(inFile, inFileName);
// Read data into an array of structs
for(int count = 0; count < SIZE; count++)
{
inFile >> arr[count].studentID >> arr[count].first_name >> arr[count].last_name >>
arr[count].exam1 >> arr[count].exam2 >> arr[count].exam3;
}
// Close input file
inFile.close();
// Get score total for each student
getTotal(arr);
// Determine grade for each student
getGrade(arr);
// Calculate lowest scores in each exam and total scores
calcLowest(arr, lowest1, lowest2, lowest3, lowest4, lowest);
// Calculate highest scores in each exam and total scores
calcHighest(arr, highest1, highest2, highest3, highest4, highest);
// Calculate average of each exam and the average of the total scores
getAverage(arr, SIZE, average1, average2, average3, average4, average);
// Calculate standard deviation of each category
getStd(arr, std1, std2, std3, std4, average1, average2, average3, average4, standardDeviation);
cout << " ";
// Print unsorted data
print(arr, lowest, highest, average, standardDeviation);
cout << " ";
// Sort data
sort(arr);
// Print sorted data
print(arr, lowest, highest, average, standardDeviation);
system("PAUSE");
return 0;
}
/**
* Pre-condition:
* Post-condition:
*/
void openInputFile(ifstream &inFile, string inFileName)
{
//Open the file
inFile.open(inFileName);
//Input validation
if (!inFile)
{
cout << "Error to open file." << endl;
cout << endl;
return;
}
}
/**
* Pre-condition:
* Post-condition:
*/
void getTotal(StudentData arr[])
{
for(int i = 0; i < SIZE; i++)
{
arr[i].total = arr[i].exam1 + arr[i].exam2 + arr[i].exam3;
}
}
/**
* Pre-condition:
* Post-condition:
*/
void getGrade(StudentData arr[])
{
for(int i = 0; i < SIZE; i++)
{
if(arr[i].total >= 270)
arr[i].ch = 'A';
else if(arr[i].total >= 240)
arr[i].ch = 'B';
else if(arr[i].total >= 210)
arr[i].ch = 'C';
else if(arr[i].total >= 180)
arr[i].ch = 'D';
else
arr[i].ch = 'F';
}
}
/**
* Pre-condition:
* Post-condition:
*/
void calcLowest(StudentData arr[], int &lowest1, int &lowest2, int &lowest3, int &lowest4, int
lowest[])
{
int smallest = 0;
lowest1 = arr[0].exam1;
lowest2 = arr[0].exam2;
lowest3 = arr[0].exam3;
lowest4 = arr[0].total;
// Loop to determine lowest score from Exam1, 2, 3, and Total
for (int i = 0; i < SIZE; i++)
{
if (lowest1 > arr[i].exam1)
{
lowest1 = arr[i].exam1;
smallest = i;
}
if (lowest2 > arr[i].exam2)
{
lowest2 = arr[i].exam2;
smallest = i;
}
if (lowest3 > arr[i].exam3)
{
lowest3 = arr[i].exam3;
smallest = i;
}
if (lowest4 > arr[i].total)
{
lowest4 = arr[i].total;
smallest = i;
}
}
// Loop lowest values into an array of size 4
for(int index = 0; index < INFO; index++)
{
if(index == 0)
lowest[0] = lowest1;
else if(index == 1)
lowest[1] = lowest2;
else if(index == 2)
lowest[2] = lowest3;
else if(index == 3)
lowest[3] = lowest4;
else
cout << "Fail!" << endl;
}
}
/**
* Pre-condition:
* Post-condition:
*/
void calcHighest(StudentData arr[], int &highest1, int &highest2, int &highest3, int &highest4,
int highest[])
{
int biggest = 0;
highest1 = arr[0].exam1;
highest2 = arr[0].exam2;
highest3 = arr[0].exam3;
highest4 = arr[0].total;
// Loop to determine highest score from Exam1, 2, 3, and Total
for (int i = 0; i < SIZE; i++)
{
if (highest1 < arr[i].exam1)
{
highest1 = arr[i].exam1;
biggest = i;
}
if (highest2 < arr[i].exam2)
{
highest2 = arr[i].exam2;
biggest = i;
}
if (highest3 < arr[i].exam3)
{
highest3 = arr[i].exam3;
biggest = i;
}
if (highest4 < arr[i].total)
{
highest4 = arr[i].total;
biggest = i;
}
}
// Loop highest values into an array of size 4
for(int index = 0; index < INFO; index++)
{
if(index == 0)
highest[0] = highest1;
else if(index == 1)
highest[1] = highest2;
else if(index == 2)
highest[2] = highest3;
else if(index == 3)
highest[3] = highest4;
else
cout << "Fail!" << endl;
}
}
/**
* Pre-condition:
* Post-condition:
*/
void getAverage(StudentData arr[], int size, double &average1, double &average2, double
&average3, double &average4, double average[])
{
int sum1 = 0, sum2 = 0, sum3 = 0, sum4 = 0;
// Get sum of each category (Exam1, 2, 3, and Total)
for(int i = 0; i < SIZE; i++)
{
sum1 += arr[i].exam1;
sum2 += arr[i].exam2;
sum3 += arr[i].exam3;
sum4 += arr[i].total;
}
// Calculate average for each category
average1 += static_cast(sum1)/size;
average2 += static_cast(sum2)/size;
average3 += static_cast(sum3)/size;
average4 += static_cast(sum4)/size;
// Loop average values into an array of size 4
for(int index = 0; index < INFO; index++)
{
if(index == 0)
average[0] = average1;
else if(index == 1)
average[1] = average2;
else if(index == 2)
average[2] = average3;
else if(index == 3)
average[3] = average4;
else
cout << "Fail!" << endl;
}
}
/**
* Pre-condition:
* Post-condition:
*/
void getStd(StudentData arr[], double &std1, double &std2, double &std3, double &std4, double
&average1, double &average2, double &average3, double &average4, double
standardDeviation[])
{
double deviationSum1 = 0, deviationSum2 = 0, deviationSum3 = 0, deviationSum4 = 0;
for(int i = 0; i < SIZE; i++)
{
deviationSum1 += pow((arr[i].exam1 - average1), 2);
deviationSum2 += pow((arr[i].exam2 - average2), 2);
deviationSum3 += pow((arr[i].exam3 - average3), 2);
deviationSum4 += pow((arr[i].total - average4), 2);
}
std1 = sqrt(deviationSum1 / ((SIZE) - 1));
std2 = sqrt(deviationSum2 / ((SIZE) - 1));
std3 = sqrt(deviationSum3 / ((SIZE) - 1));
std4 = sqrt(deviationSum4 / ((SIZE) - 1));
// Loop average values into an array of size
for(int index = 0; index < INFO; index++)
{
if(index == 0)
standardDeviation[0] = std1;
else if(index == 1)
standardDeviation[1] = std2;
else if(index == 2)
standardDeviation[2] = std3;
else if(index == 3)
standardDeviation[3] = std4;
else
cout << "Fail!" << endl;
}
}
cout << " ";
}
/**
* Pre-condition:
* Post-condition:
*/
void sort(StudentData arr[])
{
StudentData temp;
for (int i = 0; i < (SIZE - 1); i++)
{
for (int j = i + 1; j < SIZE; j++)
{
if (arr[i].last_name > arr[j].last_name)
{
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
}
}
Solution
#include "stdafx.h"
#include
#include
#include
#include
#include
using namespace std;
struct StudentData
{
int studentID;
string first_name;
string last_name;
int exam1;
int exam2;
int exam3;
int total;
char ch;
};
const int SIZE = 9;
const int INFO = 4;
// Function prototypes
void openInputFile(ifstream &, string);
void getTotal(StudentData[]);
void getGrade(StudentData[]);
void calcLowest(StudentData[], int &, int &, int &, int &, int[]);
void calcHighest(StudentData[], int &, int &, int &, int &, int[]);
void getAverage(StudentData[], int, double &, double &, double &, double &, double[]);
void getStd(StudentData[], double &, double &, double &, double &, double &, double &,
double &, double &, double[]);
void print(StudentData[], int[], int[], double[], double[]);
void sort(StudentData[]);
int main()
{
// Variables
StudentData arr[SIZE];
int lowest1, lowest2, lowest3, lowest4; // Stores lowest exam scores
int highest1, highest2, highest3, highest4; // Holds highest exam scores
double average1 = 0, average2 = 0, average3 = 0, average4 = 0; // Represents average of each
exam
double std1 = 0, std2 = 0, std3 = 0, std4 = 0; // Holds standard deviation for Exams 1-3 and
Total
int lowest[INFO] = {};
int highest[INFO] = {};
double average[INFO] = {};
double standardDeviation[INFO] = {};
ifstream inFile;
string inFileName = "C:UsersLisaDesktopscores.txt";
// Call function to read data in file
openInputFile(inFile, inFileName);
// Read data into an array of structs
for(int count = 0; count < SIZE; count++)
{
inFile >> arr[count].studentID >> arr[count].first_name >> arr[count].last_name >>
arr[count].exam1 >> arr[count].exam2 >> arr[count].exam3;
}
// Close input file
inFile.close();
// Get score total for each student
getTotal(arr);
// Determine grade for each student
getGrade(arr);
// Calculate lowest scores in each exam and total scores
calcLowest(arr, lowest1, lowest2, lowest3, lowest4, lowest);
// Calculate highest scores in each exam and total scores
calcHighest(arr, highest1, highest2, highest3, highest4, highest);
// Calculate average of each exam and the average of the total scores
getAverage(arr, SIZE, average1, average2, average3, average4, average);
// Calculate standard deviation of each category
getStd(arr, std1, std2, std3, std4, average1, average2, average3, average4, standardDeviation);
cout << " ";
// Print unsorted data
print(arr, lowest, highest, average, standardDeviation);
cout << " ";
// Sort data
sort(arr);
// Print sorted data
print(arr, lowest, highest, average, standardDeviation);
system("PAUSE");
return 0;
}
/**
* Pre-condition:
* Post-condition:
*/
void openInputFile(ifstream &inFile, string inFileName)
{
//Open the file
inFile.open(inFileName);
//Input validation
if (!inFile)
{
cout << "Error to open file." << endl;
cout << endl;
return;
}
}
/**
* Pre-condition:
* Post-condition:
*/
void getTotal(StudentData arr[])
{
for(int i = 0; i < SIZE; i++)
{
arr[i].total = arr[i].exam1 + arr[i].exam2 + arr[i].exam3;
}
}
/**
* Pre-condition:
* Post-condition:
*/
void getGrade(StudentData arr[])
{
for(int i = 0; i < SIZE; i++)
{
if(arr[i].total >= 270)
arr[i].ch = 'A';
else if(arr[i].total >= 240)
arr[i].ch = 'B';
else if(arr[i].total >= 210)
arr[i].ch = 'C';
else if(arr[i].total >= 180)
arr[i].ch = 'D';
else
arr[i].ch = 'F';
}
}
/**
* Pre-condition:
* Post-condition:
*/
void calcLowest(StudentData arr[], int &lowest1, int &lowest2, int &lowest3, int &lowest4, int
lowest[])
{
int smallest = 0;
lowest1 = arr[0].exam1;
lowest2 = arr[0].exam2;
lowest3 = arr[0].exam3;
lowest4 = arr[0].total;
// Loop to determine lowest score from Exam1, 2, 3, and Total
for (int i = 0; i < SIZE; i++)
{
if (lowest1 > arr[i].exam1)
{
lowest1 = arr[i].exam1;
smallest = i;
}
if (lowest2 > arr[i].exam2)
{
lowest2 = arr[i].exam2;
smallest = i;
}
if (lowest3 > arr[i].exam3)
{
lowest3 = arr[i].exam3;
smallest = i;
}
if (lowest4 > arr[i].total)
{
lowest4 = arr[i].total;
smallest = i;
}
}
// Loop lowest values into an array of size 4
for(int index = 0; index < INFO; index++)
{
if(index == 0)
lowest[0] = lowest1;
else if(index == 1)
lowest[1] = lowest2;
else if(index == 2)
lowest[2] = lowest3;
else if(index == 3)
lowest[3] = lowest4;
else
cout << "Fail!" << endl;
}
}
/**
* Pre-condition:
* Post-condition:
*/
void calcHighest(StudentData arr[], int &highest1, int &highest2, int &highest3, int &highest4,
int highest[])
{
int biggest = 0;
highest1 = arr[0].exam1;
highest2 = arr[0].exam2;
highest3 = arr[0].exam3;
highest4 = arr[0].total;
// Loop to determine highest score from Exam1, 2, 3, and Total
for (int i = 0; i < SIZE; i++)
{
if (highest1 < arr[i].exam1)
{
highest1 = arr[i].exam1;
biggest = i;
}
if (highest2 < arr[i].exam2)
{
highest2 = arr[i].exam2;
biggest = i;
}
if (highest3 < arr[i].exam3)
{
highest3 = arr[i].exam3;
biggest = i;
}
if (highest4 < arr[i].total)
{
highest4 = arr[i].total;
biggest = i;
}
}
// Loop highest values into an array of size 4
for(int index = 0; index < INFO; index++)
{
if(index == 0)
highest[0] = highest1;
else if(index == 1)
highest[1] = highest2;
else if(index == 2)
highest[2] = highest3;
else if(index == 3)
highest[3] = highest4;
else
cout << "Fail!" << endl;
}
}
/**
* Pre-condition:
* Post-condition:
*/
void getAverage(StudentData arr[], int size, double &average1, double &average2, double
&average3, double &average4, double average[])
{
int sum1 = 0, sum2 = 0, sum3 = 0, sum4 = 0;
// Get sum of each category (Exam1, 2, 3, and Total)
for(int i = 0; i < SIZE; i++)
{
sum1 += arr[i].exam1;
sum2 += arr[i].exam2;
sum3 += arr[i].exam3;
sum4 += arr[i].total;
}
// Calculate average for each category
average1 += static_cast(sum1)/size;
average2 += static_cast(sum2)/size;
average3 += static_cast(sum3)/size;
average4 += static_cast(sum4)/size;
// Loop average values into an array of size 4
for(int index = 0; index < INFO; index++)
{
if(index == 0)
average[0] = average1;
else if(index == 1)
average[1] = average2;
else if(index == 2)
average[2] = average3;
else if(index == 3)
average[3] = average4;
else
cout << "Fail!" << endl;
}
}
/**
* Pre-condition:
* Post-condition:
*/
void getStd(StudentData arr[], double &std1, double &std2, double &std3, double &std4, double
&average1, double &average2, double &average3, double &average4, double
standardDeviation[])
{
double deviationSum1 = 0, deviationSum2 = 0, deviationSum3 = 0, deviationSum4 = 0;
for(int i = 0; i < SIZE; i++)
{
deviationSum1 += pow((arr[i].exam1 - average1), 2);
deviationSum2 += pow((arr[i].exam2 - average2), 2);
deviationSum3 += pow((arr[i].exam3 - average3), 2);
deviationSum4 += pow((arr[i].total - average4), 2);
}
std1 = sqrt(deviationSum1 / ((SIZE) - 1));
std2 = sqrt(deviationSum2 / ((SIZE) - 1));
std3 = sqrt(deviationSum3 / ((SIZE) - 1));
std4 = sqrt(deviationSum4 / ((SIZE) - 1));
// Loop average values into an array of size
for(int index = 0; index < INFO; index++)
{
if(index == 0)
standardDeviation[0] = std1;
else if(index == 1)
standardDeviation[1] = std2;
else if(index == 2)
standardDeviation[2] = std3;
else if(index == 3)
standardDeviation[3] = std4;
else
cout << "Fail!" << endl;
}
}
cout << " ";
}
/**
* Pre-condition:
* Post-condition:
*/
void sort(StudentData arr[])
{
StudentData temp;
for (int i = 0; i < (SIZE - 1); i++)
{
for (int j = i + 1; j < SIZE; j++)
{
if (arr[i].last_name > arr[j].last_name)
{
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
}
}

More Related Content

Similar to #include stdafx.h#include iostream#include string#incl.pdf

SP-First-Lecture.ppt
SP-First-Lecture.pptSP-First-Lecture.ppt
SP-First-Lecture.pptFareedIhsas
 
java compilerCompiler1.javajava compilerCompiler1.javaimport.docx
java compilerCompiler1.javajava compilerCompiler1.javaimport.docxjava compilerCompiler1.javajava compilerCompiler1.javaimport.docx
java compilerCompiler1.javajava compilerCompiler1.javaimport.docxpriestmanmable
 
This is my code but not complete, please complete my.pdf
This is my code but not complete, please complete my.pdfThis is my code but not complete, please complete my.pdf
This is my code but not complete, please complete my.pdffashionbigchennai
 
C language concept with code apna college.pdf
C language concept with code apna college.pdfC language concept with code apna college.pdf
C language concept with code apna college.pdfmhande899
 
R57shell
R57shellR57shell
R57shellady36
 
Notes for SQLite3 Usage
Notes for SQLite3 UsageNotes for SQLite3 Usage
Notes for SQLite3 UsageWilliam Lee
 
Round PEG, Round Hole - Parsing Functionally
Round PEG, Round Hole - Parsing FunctionallyRound PEG, Round Hole - Parsing Functionally
Round PEG, Round Hole - Parsing FunctionallySean Cribbs
 
PERL for QA - Important Commands and applications
PERL for QA - Important Commands and applicationsPERL for QA - Important Commands and applications
PERL for QA - Important Commands and applicationsSunil Kumar Gunasekaran
 
The purpose of this C++ programming project is to allow the student .pdf
The purpose of this C++ programming project is to allow the student .pdfThe purpose of this C++ programming project is to allow the student .pdf
The purpose of this C++ programming project is to allow the student .pdfRahul04August
 
Programming Fundamentals Arrays and Strings
Programming Fundamentals   Arrays and Strings Programming Fundamentals   Arrays and Strings
Programming Fundamentals Arrays and Strings imtiazalijoono
 
HELP IN JAVACreate a main method and use these input files to tes.pdf
HELP IN JAVACreate a main method and use these input files to tes.pdfHELP IN JAVACreate a main method and use these input files to tes.pdf
HELP IN JAVACreate a main method and use these input files to tes.pdffatoryoutlets
 
sodapdf-converted into ppt presentation(1).pdf
sodapdf-converted into ppt presentation(1).pdfsodapdf-converted into ppt presentation(1).pdf
sodapdf-converted into ppt presentation(1).pdfMuhammadMaazShaik
 
VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2YOGESH SINGH
 
Write a Matlab code (a computerized program) for calculating plane st.docx
 Write a Matlab code (a computerized program) for calculating plane st.docx Write a Matlab code (a computerized program) for calculating plane st.docx
Write a Matlab code (a computerized program) for calculating plane st.docxajoy21
 

Similar to #include stdafx.h#include iostream#include string#incl.pdf (20)

SP-First-Lecture.ppt
SP-First-Lecture.pptSP-First-Lecture.ppt
SP-First-Lecture.ppt
 
java compilerCompiler1.javajava compilerCompiler1.javaimport.docx
java compilerCompiler1.javajava compilerCompiler1.javaimport.docxjava compilerCompiler1.javajava compilerCompiler1.javaimport.docx
java compilerCompiler1.javajava compilerCompiler1.javaimport.docx
 
This is my code but not complete, please complete my.pdf
This is my code but not complete, please complete my.pdfThis is my code but not complete, please complete my.pdf
This is my code but not complete, please complete my.pdf
 
C++ L07-Struct
C++ L07-StructC++ L07-Struct
C++ L07-Struct
 
Vcs16
Vcs16Vcs16
Vcs16
 
C language concept with code apna college.pdf
C language concept with code apna college.pdfC language concept with code apna college.pdf
C language concept with code apna college.pdf
 
R57shell
R57shellR57shell
R57shell
 
Notes for SQLite3 Usage
Notes for SQLite3 UsageNotes for SQLite3 Usage
Notes for SQLite3 Usage
 
Round PEG, Round Hole - Parsing Functionally
Round PEG, Round Hole - Parsing FunctionallyRound PEG, Round Hole - Parsing Functionally
Round PEG, Round Hole - Parsing Functionally
 
Codes on structures
Codes on structuresCodes on structures
Codes on structures
 
PERL for QA - Important Commands and applications
PERL for QA - Important Commands and applicationsPERL for QA - Important Commands and applications
PERL for QA - Important Commands and applications
 
The purpose of this C++ programming project is to allow the student .pdf
The purpose of this C++ programming project is to allow the student .pdfThe purpose of this C++ programming project is to allow the student .pdf
The purpose of this C++ programming project is to allow the student .pdf
 
901131 examples
901131 examples901131 examples
901131 examples
 
A Test of Strength
A Test of StrengthA Test of Strength
A Test of Strength
 
Programming Fundamentals Arrays and Strings
Programming Fundamentals   Arrays and Strings Programming Fundamentals   Arrays and Strings
Programming Fundamentals Arrays and Strings
 
HELP IN JAVACreate a main method and use these input files to tes.pdf
HELP IN JAVACreate a main method and use these input files to tes.pdfHELP IN JAVACreate a main method and use these input files to tes.pdf
HELP IN JAVACreate a main method and use these input files to tes.pdf
 
sodapdf-converted into ppt presentation(1).pdf
sodapdf-converted into ppt presentation(1).pdfsodapdf-converted into ppt presentation(1).pdf
sodapdf-converted into ppt presentation(1).pdf
 
C programs
C programsC programs
C programs
 
VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2
 
Write a Matlab code (a computerized program) for calculating plane st.docx
 Write a Matlab code (a computerized program) for calculating plane st.docx Write a Matlab code (a computerized program) for calculating plane st.docx
Write a Matlab code (a computerized program) for calculating plane st.docx
 

More from anonamobilesp

B You are looking to find a buffer solution. A buffer is made by mix.pdf
  B You are looking to find a buffer solution. A buffer is made by mix.pdf  B You are looking to find a buffer solution. A buffer is made by mix.pdf
B You are looking to find a buffer solution. A buffer is made by mix.pdfanonamobilesp
 
you will see brisk effervesence of hydrogen gas a.pdf
                     you will see brisk effervesence of hydrogen gas a.pdf                     you will see brisk effervesence of hydrogen gas a.pdf
you will see brisk effervesence of hydrogen gas a.pdfanonamobilesp
 
water, propyne, ethene, methane,methylamine .pdf
                     water, propyne, ethene, methane,methylamine      .pdf                     water, propyne, ethene, methane,methylamine      .pdf
water, propyne, ethene, methane,methylamine .pdfanonamobilesp
 
Solution At equilibrium we can write equation as.pdf
                     Solution At equilibrium we can write equation as.pdf                     Solution At equilibrium we can write equation as.pdf
Solution At equilibrium we can write equation as.pdfanonamobilesp
 
take the mean of the values and then find the var.pdf
                     take the mean of the values and then find the var.pdf                     take the mean of the values and then find the var.pdf
take the mean of the values and then find the var.pdfanonamobilesp
 
Perchloric acid is very strong acid. So the conju.pdf
                     Perchloric acid is very strong acid. So the conju.pdf                     Perchloric acid is very strong acid. So the conju.pdf
Perchloric acid is very strong acid. So the conju.pdfanonamobilesp
 
NaOH + HCl = NaCl + H2O .pdf
                     NaOH + HCl = NaCl  + H2O                         .pdf                     NaOH + HCl = NaCl  + H2O                         .pdf
NaOH + HCl = NaCl + H2O .pdfanonamobilesp
 
Kw= [H+][OH-] =1x10^-14 at 25 degrees celsius. We.pdf
                     Kw= [H+][OH-] =1x10^-14 at 25 degrees celsius. We.pdf                     Kw= [H+][OH-] =1x10^-14 at 25 degrees celsius. We.pdf
Kw= [H+][OH-] =1x10^-14 at 25 degrees celsius. We.pdfanonamobilesp
 
London-dispersion forces .pdf
                     London-dispersion forces                         .pdf                     London-dispersion forces                         .pdf
London-dispersion forces .pdfanonamobilesp
 
mass = mass of solute (mass of solute + solven.pdf
                     mass = mass of solute  (mass of solute + solven.pdf                     mass = mass of solute  (mass of solute + solven.pdf
mass = mass of solute (mass of solute + solven.pdfanonamobilesp
 
We have different types of Storage Networks like direct-attached sto.pdf
We have different types of Storage Networks like direct-attached sto.pdfWe have different types of Storage Networks like direct-attached sto.pdf
We have different types of Storage Networks like direct-attached sto.pdfanonamobilesp
 
e.) One solvent cannot dissolve the sample if non.pdf
                     e.) One solvent cannot dissolve the sample if non.pdf                     e.) One solvent cannot dissolve the sample if non.pdf
e.) One solvent cannot dissolve the sample if non.pdfanonamobilesp
 
data is insufficient .pdf
                     data is insufficient                             .pdf                     data is insufficient                             .pdf
data is insufficient .pdfanonamobilesp
 
The difference between cyclic and non-cyclic electron transportNON.pdf
The difference between cyclic and non-cyclic electron transportNON.pdfThe difference between cyclic and non-cyclic electron transportNON.pdf
The difference between cyclic and non-cyclic electron transportNON.pdfanonamobilesp
 
The answer is C) H2SO4An Arrhenius acid dissociates in aqueous so.pdf
The answer is C) H2SO4An Arrhenius acid dissociates in aqueous so.pdfThe answer is C) H2SO4An Arrhenius acid dissociates in aqueous so.pdf
The answer is C) H2SO4An Arrhenius acid dissociates in aqueous so.pdfanonamobilesp
 
covalent bond Solution co.pdf
                     covalent bond Solution                     co.pdf                     covalent bond Solution                     co.pdf
covalent bond Solution co.pdfanonamobilesp
 
c. presence of isotopes of both carbon and hydrog.pdf
                     c. presence of isotopes of both carbon and hydrog.pdf                     c. presence of isotopes of both carbon and hydrog.pdf
c. presence of isotopes of both carbon and hydrog.pdfanonamobilesp
 
CAFR is a set of U.S. government financial statements comprising the.pdf
CAFR is a set of U.S. government financial statements comprising the.pdfCAFR is a set of U.S. government financial statements comprising the.pdf
CAFR is a set of U.S. government financial statements comprising the.pdfanonamobilesp
 
Puerto Rico BoaRangeThe Puerto Rican boa is endemic to Puerto R.pdf
Puerto Rico BoaRangeThe Puerto Rican boa is endemic to Puerto R.pdfPuerto Rico BoaRangeThe Puerto Rican boa is endemic to Puerto R.pdf
Puerto Rico BoaRangeThe Puerto Rican boa is endemic to Puerto R.pdfanonamobilesp
 
Media access controlSolutionMedia access control.pdf
Media access controlSolutionMedia access control.pdfMedia access controlSolutionMedia access control.pdf
Media access controlSolutionMedia access control.pdfanonamobilesp
 

More from anonamobilesp (20)

B You are looking to find a buffer solution. A buffer is made by mix.pdf
  B You are looking to find a buffer solution. A buffer is made by mix.pdf  B You are looking to find a buffer solution. A buffer is made by mix.pdf
B You are looking to find a buffer solution. A buffer is made by mix.pdf
 
you will see brisk effervesence of hydrogen gas a.pdf
                     you will see brisk effervesence of hydrogen gas a.pdf                     you will see brisk effervesence of hydrogen gas a.pdf
you will see brisk effervesence of hydrogen gas a.pdf
 
water, propyne, ethene, methane,methylamine .pdf
                     water, propyne, ethene, methane,methylamine      .pdf                     water, propyne, ethene, methane,methylamine      .pdf
water, propyne, ethene, methane,methylamine .pdf
 
Solution At equilibrium we can write equation as.pdf
                     Solution At equilibrium we can write equation as.pdf                     Solution At equilibrium we can write equation as.pdf
Solution At equilibrium we can write equation as.pdf
 
take the mean of the values and then find the var.pdf
                     take the mean of the values and then find the var.pdf                     take the mean of the values and then find the var.pdf
take the mean of the values and then find the var.pdf
 
Perchloric acid is very strong acid. So the conju.pdf
                     Perchloric acid is very strong acid. So the conju.pdf                     Perchloric acid is very strong acid. So the conju.pdf
Perchloric acid is very strong acid. So the conju.pdf
 
NaOH + HCl = NaCl + H2O .pdf
                     NaOH + HCl = NaCl  + H2O                         .pdf                     NaOH + HCl = NaCl  + H2O                         .pdf
NaOH + HCl = NaCl + H2O .pdf
 
Kw= [H+][OH-] =1x10^-14 at 25 degrees celsius. We.pdf
                     Kw= [H+][OH-] =1x10^-14 at 25 degrees celsius. We.pdf                     Kw= [H+][OH-] =1x10^-14 at 25 degrees celsius. We.pdf
Kw= [H+][OH-] =1x10^-14 at 25 degrees celsius. We.pdf
 
London-dispersion forces .pdf
                     London-dispersion forces                         .pdf                     London-dispersion forces                         .pdf
London-dispersion forces .pdf
 
mass = mass of solute (mass of solute + solven.pdf
                     mass = mass of solute  (mass of solute + solven.pdf                     mass = mass of solute  (mass of solute + solven.pdf
mass = mass of solute (mass of solute + solven.pdf
 
We have different types of Storage Networks like direct-attached sto.pdf
We have different types of Storage Networks like direct-attached sto.pdfWe have different types of Storage Networks like direct-attached sto.pdf
We have different types of Storage Networks like direct-attached sto.pdf
 
e.) One solvent cannot dissolve the sample if non.pdf
                     e.) One solvent cannot dissolve the sample if non.pdf                     e.) One solvent cannot dissolve the sample if non.pdf
e.) One solvent cannot dissolve the sample if non.pdf
 
data is insufficient .pdf
                     data is insufficient                             .pdf                     data is insufficient                             .pdf
data is insufficient .pdf
 
The difference between cyclic and non-cyclic electron transportNON.pdf
The difference between cyclic and non-cyclic electron transportNON.pdfThe difference between cyclic and non-cyclic electron transportNON.pdf
The difference between cyclic and non-cyclic electron transportNON.pdf
 
The answer is C) H2SO4An Arrhenius acid dissociates in aqueous so.pdf
The answer is C) H2SO4An Arrhenius acid dissociates in aqueous so.pdfThe answer is C) H2SO4An Arrhenius acid dissociates in aqueous so.pdf
The answer is C) H2SO4An Arrhenius acid dissociates in aqueous so.pdf
 
covalent bond Solution co.pdf
                     covalent bond Solution                     co.pdf                     covalent bond Solution                     co.pdf
covalent bond Solution co.pdf
 
c. presence of isotopes of both carbon and hydrog.pdf
                     c. presence of isotopes of both carbon and hydrog.pdf                     c. presence of isotopes of both carbon and hydrog.pdf
c. presence of isotopes of both carbon and hydrog.pdf
 
CAFR is a set of U.S. government financial statements comprising the.pdf
CAFR is a set of U.S. government financial statements comprising the.pdfCAFR is a set of U.S. government financial statements comprising the.pdf
CAFR is a set of U.S. government financial statements comprising the.pdf
 
Puerto Rico BoaRangeThe Puerto Rican boa is endemic to Puerto R.pdf
Puerto Rico BoaRangeThe Puerto Rican boa is endemic to Puerto R.pdfPuerto Rico BoaRangeThe Puerto Rican boa is endemic to Puerto R.pdf
Puerto Rico BoaRangeThe Puerto Rican boa is endemic to Puerto R.pdf
 
Media access controlSolutionMedia access control.pdf
Media access controlSolutionMedia access control.pdfMedia access controlSolutionMedia access control.pdf
Media access controlSolutionMedia access control.pdf
 

Recently uploaded

Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportDenish Jangid
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptxVishal Singh
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code ExamplesPeter Brusilovsky
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...Nguyen Thanh Tu Collection
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSean M. Fox
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFVivekanand Anglo Vedic Academy
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjMohammed Sikander
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxMarlene Maheu
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17Celine George
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnershipsexpandedwebsite
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17Celine George
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismDabee Kamal
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxCeline George
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptNishitharanjan Rout
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesAmanpreetKaur157993
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppCeline George
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMELOISARIVERA8
 

Recently uploaded (20)

Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptx
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDF
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptx
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategies
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 

#include stdafx.h#include iostream#include string#incl.pdf

  • 1. #include "stdafx.h" #include #include #include #include #include using namespace std; struct StudentData { int studentID; string first_name; string last_name; int exam1; int exam2; int exam3; int total; char ch; }; const int SIZE = 9; const int INFO = 4; // Function prototypes void openInputFile(ifstream &, string); void getTotal(StudentData[]); void getGrade(StudentData[]); void calcLowest(StudentData[], int &, int &, int &, int &, int[]); void calcHighest(StudentData[], int &, int &, int &, int &, int[]); void getAverage(StudentData[], int, double &, double &, double &, double &, double[]); void getStd(StudentData[], double &, double &, double &, double &, double &, double &, double &, double &, double[]); void print(StudentData[], int[], int[], double[], double[]); void sort(StudentData[]); int main() { // Variables StudentData arr[SIZE];
  • 2. int lowest1, lowest2, lowest3, lowest4; // Stores lowest exam scores int highest1, highest2, highest3, highest4; // Holds highest exam scores double average1 = 0, average2 = 0, average3 = 0, average4 = 0; // Represents average of each exam double std1 = 0, std2 = 0, std3 = 0, std4 = 0; // Holds standard deviation for Exams 1-3 and Total int lowest[INFO] = {}; int highest[INFO] = {}; double average[INFO] = {}; double standardDeviation[INFO] = {}; ifstream inFile; string inFileName = "C:UsersLisaDesktopscores.txt"; // Call function to read data in file openInputFile(inFile, inFileName); // Read data into an array of structs for(int count = 0; count < SIZE; count++) { inFile >> arr[count].studentID >> arr[count].first_name >> arr[count].last_name >> arr[count].exam1 >> arr[count].exam2 >> arr[count].exam3; } // Close input file inFile.close(); // Get score total for each student getTotal(arr); // Determine grade for each student getGrade(arr); // Calculate lowest scores in each exam and total scores calcLowest(arr, lowest1, lowest2, lowest3, lowest4, lowest); // Calculate highest scores in each exam and total scores calcHighest(arr, highest1, highest2, highest3, highest4, highest); // Calculate average of each exam and the average of the total scores getAverage(arr, SIZE, average1, average2, average3, average4, average); // Calculate standard deviation of each category getStd(arr, std1, std2, std3, std4, average1, average2, average3, average4, standardDeviation); cout << " "; // Print unsorted data
  • 3. print(arr, lowest, highest, average, standardDeviation); cout << " "; // Sort data sort(arr); // Print sorted data print(arr, lowest, highest, average, standardDeviation); system("PAUSE"); return 0; } /** * Pre-condition: * Post-condition: */ void openInputFile(ifstream &inFile, string inFileName) { //Open the file inFile.open(inFileName); //Input validation if (!inFile) { cout << "Error to open file." << endl; cout << endl; return; } } /** * Pre-condition: * Post-condition: */ void getTotal(StudentData arr[]) { for(int i = 0; i < SIZE; i++) { arr[i].total = arr[i].exam1 + arr[i].exam2 + arr[i].exam3; } }
  • 4. /** * Pre-condition: * Post-condition: */ void getGrade(StudentData arr[]) { for(int i = 0; i < SIZE; i++) { if(arr[i].total >= 270) arr[i].ch = 'A'; else if(arr[i].total >= 240) arr[i].ch = 'B'; else if(arr[i].total >= 210) arr[i].ch = 'C'; else if(arr[i].total >= 180) arr[i].ch = 'D'; else arr[i].ch = 'F'; } } /** * Pre-condition: * Post-condition: */ void calcLowest(StudentData arr[], int &lowest1, int &lowest2, int &lowest3, int &lowest4, int lowest[]) { int smallest = 0; lowest1 = arr[0].exam1; lowest2 = arr[0].exam2; lowest3 = arr[0].exam3; lowest4 = arr[0].total; // Loop to determine lowest score from Exam1, 2, 3, and Total for (int i = 0; i < SIZE; i++) { if (lowest1 > arr[i].exam1)
  • 5. { lowest1 = arr[i].exam1; smallest = i; } if (lowest2 > arr[i].exam2) { lowest2 = arr[i].exam2; smallest = i; } if (lowest3 > arr[i].exam3) { lowest3 = arr[i].exam3; smallest = i; } if (lowest4 > arr[i].total) { lowest4 = arr[i].total; smallest = i; } } // Loop lowest values into an array of size 4 for(int index = 0; index < INFO; index++) { if(index == 0) lowest[0] = lowest1; else if(index == 1) lowest[1] = lowest2; else if(index == 2) lowest[2] = lowest3; else if(index == 3) lowest[3] = lowest4; else cout << "Fail!" << endl; } } /**
  • 6. * Pre-condition: * Post-condition: */ void calcHighest(StudentData arr[], int &highest1, int &highest2, int &highest3, int &highest4, int highest[]) { int biggest = 0; highest1 = arr[0].exam1; highest2 = arr[0].exam2; highest3 = arr[0].exam3; highest4 = arr[0].total; // Loop to determine highest score from Exam1, 2, 3, and Total for (int i = 0; i < SIZE; i++) { if (highest1 < arr[i].exam1) { highest1 = arr[i].exam1; biggest = i; } if (highest2 < arr[i].exam2) { highest2 = arr[i].exam2; biggest = i; } if (highest3 < arr[i].exam3) { highest3 = arr[i].exam3; biggest = i; } if (highest4 < arr[i].total) { highest4 = arr[i].total; biggest = i; } } // Loop highest values into an array of size 4
  • 7. for(int index = 0; index < INFO; index++) { if(index == 0) highest[0] = highest1; else if(index == 1) highest[1] = highest2; else if(index == 2) highest[2] = highest3; else if(index == 3) highest[3] = highest4; else cout << "Fail!" << endl; } } /** * Pre-condition: * Post-condition: */ void getAverage(StudentData arr[], int size, double &average1, double &average2, double &average3, double &average4, double average[]) { int sum1 = 0, sum2 = 0, sum3 = 0, sum4 = 0; // Get sum of each category (Exam1, 2, 3, and Total) for(int i = 0; i < SIZE; i++) { sum1 += arr[i].exam1; sum2 += arr[i].exam2; sum3 += arr[i].exam3; sum4 += arr[i].total; } // Calculate average for each category average1 += static_cast(sum1)/size; average2 += static_cast(sum2)/size; average3 += static_cast(sum3)/size; average4 += static_cast(sum4)/size; // Loop average values into an array of size 4
  • 8. for(int index = 0; index < INFO; index++) { if(index == 0) average[0] = average1; else if(index == 1) average[1] = average2; else if(index == 2) average[2] = average3; else if(index == 3) average[3] = average4; else cout << "Fail!" << endl; } } /** * Pre-condition: * Post-condition: */ void getStd(StudentData arr[], double &std1, double &std2, double &std3, double &std4, double &average1, double &average2, double &average3, double &average4, double standardDeviation[]) { double deviationSum1 = 0, deviationSum2 = 0, deviationSum3 = 0, deviationSum4 = 0; for(int i = 0; i < SIZE; i++) { deviationSum1 += pow((arr[i].exam1 - average1), 2); deviationSum2 += pow((arr[i].exam2 - average2), 2); deviationSum3 += pow((arr[i].exam3 - average3), 2); deviationSum4 += pow((arr[i].total - average4), 2); } std1 = sqrt(deviationSum1 / ((SIZE) - 1)); std2 = sqrt(deviationSum2 / ((SIZE) - 1)); std3 = sqrt(deviationSum3 / ((SIZE) - 1)); std4 = sqrt(deviationSum4 / ((SIZE) - 1)); // Loop average values into an array of size for(int index = 0; index < INFO; index++)
  • 9. { if(index == 0) standardDeviation[0] = std1; else if(index == 1) standardDeviation[1] = std2; else if(index == 2) standardDeviation[2] = std3; else if(index == 3) standardDeviation[3] = std4; else cout << "Fail!" << endl; } } cout << " "; } /** * Pre-condition: * Post-condition: */ void sort(StudentData arr[]) { StudentData temp; for (int i = 0; i < (SIZE - 1); i++) { for (int j = i + 1; j < SIZE; j++) { if (arr[i].last_name > arr[j].last_name) { temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } } } }
  • 10. Solution #include "stdafx.h" #include #include #include #include #include using namespace std; struct StudentData { int studentID; string first_name; string last_name; int exam1; int exam2; int exam3; int total; char ch; }; const int SIZE = 9; const int INFO = 4; // Function prototypes void openInputFile(ifstream &, string); void getTotal(StudentData[]); void getGrade(StudentData[]); void calcLowest(StudentData[], int &, int &, int &, int &, int[]); void calcHighest(StudentData[], int &, int &, int &, int &, int[]); void getAverage(StudentData[], int, double &, double &, double &, double &, double[]); void getStd(StudentData[], double &, double &, double &, double &, double &, double &, double &, double &, double[]); void print(StudentData[], int[], int[], double[], double[]); void sort(StudentData[]); int main() { // Variables
  • 11. StudentData arr[SIZE]; int lowest1, lowest2, lowest3, lowest4; // Stores lowest exam scores int highest1, highest2, highest3, highest4; // Holds highest exam scores double average1 = 0, average2 = 0, average3 = 0, average4 = 0; // Represents average of each exam double std1 = 0, std2 = 0, std3 = 0, std4 = 0; // Holds standard deviation for Exams 1-3 and Total int lowest[INFO] = {}; int highest[INFO] = {}; double average[INFO] = {}; double standardDeviation[INFO] = {}; ifstream inFile; string inFileName = "C:UsersLisaDesktopscores.txt"; // Call function to read data in file openInputFile(inFile, inFileName); // Read data into an array of structs for(int count = 0; count < SIZE; count++) { inFile >> arr[count].studentID >> arr[count].first_name >> arr[count].last_name >> arr[count].exam1 >> arr[count].exam2 >> arr[count].exam3; } // Close input file inFile.close(); // Get score total for each student getTotal(arr); // Determine grade for each student getGrade(arr); // Calculate lowest scores in each exam and total scores calcLowest(arr, lowest1, lowest2, lowest3, lowest4, lowest); // Calculate highest scores in each exam and total scores calcHighest(arr, highest1, highest2, highest3, highest4, highest); // Calculate average of each exam and the average of the total scores getAverage(arr, SIZE, average1, average2, average3, average4, average); // Calculate standard deviation of each category getStd(arr, std1, std2, std3, std4, average1, average2, average3, average4, standardDeviation); cout << " ";
  • 12. // Print unsorted data print(arr, lowest, highest, average, standardDeviation); cout << " "; // Sort data sort(arr); // Print sorted data print(arr, lowest, highest, average, standardDeviation); system("PAUSE"); return 0; } /** * Pre-condition: * Post-condition: */ void openInputFile(ifstream &inFile, string inFileName) { //Open the file inFile.open(inFileName); //Input validation if (!inFile) { cout << "Error to open file." << endl; cout << endl; return; } } /** * Pre-condition: * Post-condition: */ void getTotal(StudentData arr[]) { for(int i = 0; i < SIZE; i++) { arr[i].total = arr[i].exam1 + arr[i].exam2 + arr[i].exam3; }
  • 13. } /** * Pre-condition: * Post-condition: */ void getGrade(StudentData arr[]) { for(int i = 0; i < SIZE; i++) { if(arr[i].total >= 270) arr[i].ch = 'A'; else if(arr[i].total >= 240) arr[i].ch = 'B'; else if(arr[i].total >= 210) arr[i].ch = 'C'; else if(arr[i].total >= 180) arr[i].ch = 'D'; else arr[i].ch = 'F'; } } /** * Pre-condition: * Post-condition: */ void calcLowest(StudentData arr[], int &lowest1, int &lowest2, int &lowest3, int &lowest4, int lowest[]) { int smallest = 0; lowest1 = arr[0].exam1; lowest2 = arr[0].exam2; lowest3 = arr[0].exam3; lowest4 = arr[0].total; // Loop to determine lowest score from Exam1, 2, 3, and Total for (int i = 0; i < SIZE; i++) {
  • 14. if (lowest1 > arr[i].exam1) { lowest1 = arr[i].exam1; smallest = i; } if (lowest2 > arr[i].exam2) { lowest2 = arr[i].exam2; smallest = i; } if (lowest3 > arr[i].exam3) { lowest3 = arr[i].exam3; smallest = i; } if (lowest4 > arr[i].total) { lowest4 = arr[i].total; smallest = i; } } // Loop lowest values into an array of size 4 for(int index = 0; index < INFO; index++) { if(index == 0) lowest[0] = lowest1; else if(index == 1) lowest[1] = lowest2; else if(index == 2) lowest[2] = lowest3; else if(index == 3) lowest[3] = lowest4; else cout << "Fail!" << endl; } }
  • 15. /** * Pre-condition: * Post-condition: */ void calcHighest(StudentData arr[], int &highest1, int &highest2, int &highest3, int &highest4, int highest[]) { int biggest = 0; highest1 = arr[0].exam1; highest2 = arr[0].exam2; highest3 = arr[0].exam3; highest4 = arr[0].total; // Loop to determine highest score from Exam1, 2, 3, and Total for (int i = 0; i < SIZE; i++) { if (highest1 < arr[i].exam1) { highest1 = arr[i].exam1; biggest = i; } if (highest2 < arr[i].exam2) { highest2 = arr[i].exam2; biggest = i; } if (highest3 < arr[i].exam3) { highest3 = arr[i].exam3; biggest = i; } if (highest4 < arr[i].total) { highest4 = arr[i].total; biggest = i; } }
  • 16. // Loop highest values into an array of size 4 for(int index = 0; index < INFO; index++) { if(index == 0) highest[0] = highest1; else if(index == 1) highest[1] = highest2; else if(index == 2) highest[2] = highest3; else if(index == 3) highest[3] = highest4; else cout << "Fail!" << endl; } } /** * Pre-condition: * Post-condition: */ void getAverage(StudentData arr[], int size, double &average1, double &average2, double &average3, double &average4, double average[]) { int sum1 = 0, sum2 = 0, sum3 = 0, sum4 = 0; // Get sum of each category (Exam1, 2, 3, and Total) for(int i = 0; i < SIZE; i++) { sum1 += arr[i].exam1; sum2 += arr[i].exam2; sum3 += arr[i].exam3; sum4 += arr[i].total; } // Calculate average for each category average1 += static_cast(sum1)/size; average2 += static_cast(sum2)/size; average3 += static_cast(sum3)/size; average4 += static_cast(sum4)/size;
  • 17. // Loop average values into an array of size 4 for(int index = 0; index < INFO; index++) { if(index == 0) average[0] = average1; else if(index == 1) average[1] = average2; else if(index == 2) average[2] = average3; else if(index == 3) average[3] = average4; else cout << "Fail!" << endl; } } /** * Pre-condition: * Post-condition: */ void getStd(StudentData arr[], double &std1, double &std2, double &std3, double &std4, double &average1, double &average2, double &average3, double &average4, double standardDeviation[]) { double deviationSum1 = 0, deviationSum2 = 0, deviationSum3 = 0, deviationSum4 = 0; for(int i = 0; i < SIZE; i++) { deviationSum1 += pow((arr[i].exam1 - average1), 2); deviationSum2 += pow((arr[i].exam2 - average2), 2); deviationSum3 += pow((arr[i].exam3 - average3), 2); deviationSum4 += pow((arr[i].total - average4), 2); } std1 = sqrt(deviationSum1 / ((SIZE) - 1)); std2 = sqrt(deviationSum2 / ((SIZE) - 1)); std3 = sqrt(deviationSum3 / ((SIZE) - 1)); std4 = sqrt(deviationSum4 / ((SIZE) - 1)); // Loop average values into an array of size
  • 18. for(int index = 0; index < INFO; index++) { if(index == 0) standardDeviation[0] = std1; else if(index == 1) standardDeviation[1] = std2; else if(index == 2) standardDeviation[2] = std3; else if(index == 3) standardDeviation[3] = std4; else cout << "Fail!" << endl; } } cout << " "; } /** * Pre-condition: * Post-condition: */ void sort(StudentData arr[]) { StudentData temp; for (int i = 0; i < (SIZE - 1); i++) { for (int j = i + 1; j < SIZE; j++) { if (arr[i].last_name > arr[j].last_name) { temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } } } }