xiikryssiix 36 Light Poster

ok. im pretty much done with this small program my teacher asked us to write.

my problem is:
it wont give me how many scores there are above average.
it keeps giving me 0. i dont get it.

maybe im overlooking something?
i think something is wrong in my // count#of scores > average area. if someone can take a look at it and kinda point it out to me, itd be awesome. thank u!

#include <iostream>
using namespace std;

struct Score
{
  int value;
  Score* next;
};


int main()
{    
  
  // create an empty linked list
  Score* head = 0;
  
  // prompt for how many students
  int nScores;
  cout << "How many scores would you like to view? ";
  cin >> nScores;
  cin.ignore(1000, 10);
  cout << " " << endl;
  
  for (int count = 0; count < nScores; count++)
  {
  //create a node 
  Score* aScore = new Score;
  cout << "Enter score [-1 to quit]: ";
  cin >> aScore->value;
  cin.ignore(1000, 10);
  
  // check for sentinel value
  if (aScore->value == -1) break;
  
  // add node to list (stack model)
  aScore->next = head;
  head = aScore;
  }
  
  // traverse list
  int sum = 0;
  int count = 0;
  Score* p;
  for (p = head; p; p = p->next)
  {
     sum += p->value;
     count++;  
  }
  
  // print results
  if (count > 0)
  { 
    float average = float(sum) / count;
    cout << "The average of " << count << " scores is " << average << endl;
  }
  else 
    cout << "No values were entered." << endl;
  
  
  // count#of scores > average
  int nGreater = 0;
  float average;
  for (count = 0; count > 0; count++)
  {
    if (nScores > average) nGreater++;
  }
  cout << nGreater << " scores are greater than average." << endl;
  
  cin.ignore();
  cin.get();
  return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.