Lepre

Lepre

  • NA
  • 1
  • 1.9k

c# print out number of sellers per level

Oct 26 2012 10:31 PM
Hi! I'm very new to C# and is having a bit of a loop problem. At the moment I have a group of sellers that needs to be counted by the amount of articles sold. They are already assigned to their respective level by the following conditions: if (seller[i].articles < 50) seller[i].level = 1; if (seller[i].articles >= 50 && seller[i].articles < 100) seller[i].level = 2; if (seller[i].articles >= 100 && seller[i].articles < 200) seller[i].level = 3; if (seller[i].articles >= 200) seller[i].level = 4; However, a slight problem arises when I want to count how many of the sellers that actually are in respective level. This might lend a clue to figure out what I'm trying to achieve: int count = 0; for (int i = 0; i < 3; i++) { if (seller[i].level == i) count++; Console.WriteLine("Numbers of sellers in level {0}: {1}", seller[i].level, count); } Regards, L

Answers (1)