This is the first program that i've written myself, i've been using one of those learn C++
in 21 days books and links from daniweb to learn. Using daniweb is a whole lot less boring than reading that crappy book. I'm just looking for a review, some advice, anything about my program and/or any advice you wish to give, thx in advance.
// enter 5 test scores
//takes the lowest score out of the equation and finds the average of the remaining 4 scores
//credit goes out to naya22 from daniweb for the program idea
#include "ScoreChop.h"
#include <iostream>
using namespace std;
int main()
{
ScoreChop sessionOne;
sessionOne.EntScores();
sessionOne.FindLow();
sessionOne.AvgScores();
cin.get();
cin.get();
return 0;
}
#include <iostream>
#include <vector>
using namespace std;
class ScoreChop
{
public:
ScoreChop();
~ScoreChop();
void EntScores();
int FindLow();
void AvgScores();
private:
int loScore;
int avgScore;
int score1;
int score2;
int score3;
int score4;
int score5;
vector<int> scoreList;
};
ScoreChop::ScoreChop()
{
score1 = 0;
score2 = 0;
score3 = 0;
score4 = 0;
score5 = 0;
loScore = 0;
avgScore = 0;
scoreList.push_back(score1);
scoreList.push_back(score2);
scoreList.push_back(score3);
scoreList.push_back(score4);
scoreList.push_back(score5);
}
ScoreChop::~ScoreChop()
{
}
void ScoreChop::EntScores()
{
for(int i = 0; i < 5; i++)
{
cout << "Enter test score " << i + 1 << ": ";
cin >> scoreList[i];
cout << endl;
}
}
int ScoreChop::FindLow()
{
loScore = scoreList[0];
for(int i = 1; i < 5; i++)
{
if(loScore > scoreList[i])
loScore = scoreList[i];
}
cout << "The lowest score was " << loScore << "." << endl;
return loScore;
}
void ScoreChop::AvgScores()
{
for (int i = 0; i < 5; i++)
{
avgScore += scoreList[i];
}
cout << "the average score minus the lowest score was: " << (avgScore - loScore)/4;
cout << endl;
}
Christopher