?
Solved

Scoring System

Posted on 2011-10-01
10
Medium Priority
?
876 Views
Last Modified: 2012-05-12
Experts,

Details
I am trying to create a scoring system where the user will input names and scores of all players. The program will calculate the average score and display all the players who scored below average.  

Sample Output
Enter Player Name (Q to quit): Bob

Enter score for Bob: 3245

Enter Player Name (Q to quit): Sue

Enter score for Sue: 1098
Enter Player Name (Q to quit): Q

Name     Score

Bob        3245

Sue        1098
Average Score: 3944.75

Players who scored below average

Name     Score

Bob        3245
Sue        1098

Variables
My variables are:
 InputData( ): Requests the user to input the player names and scores from the user and stores them into the two arrays for an unknown number of players <= 100.  
DisplayPlayerData(): Displays each player's name and score.
CalculateAverageScore( ): Calculates the average score and returns it by value.  
DisplayBelowAverage( ): Displays the names and scores of players who scored below average.

Comments
Any ideas how to tackle this? New to C#, trying to figure out the code

Thank you very much in advance!

0
Comment
Question by:Michael Reeve
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 36898406
Obviously homework...what have you done so far?
0
 

Author Comment

by:Michael Reeve
ID: 36898409
Yes, that obvious, huh. I have identified the methods. How can I get the names and scores from the user and place them into an array?
using System;

namespace Wk5_LabA
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] playerNameAr = new string[100];
            double[] scoreAr = new double[100];
            int numPlayers = 0;
            double averageScore;


            static void InputData(playerNameAr, scoreAr, ref numPlayers);
            Console.WriteLine("Please enter");
            
            foreach  string(string playerNameAr in playerName)
            {
                Console.WriteLine(playerNameAr)
            };
            Console.ReadLine();


            static void DisplayPlayerData(playerNameAr, scoreAr, numPlayers);

            static void averageScore = CalculateAverageScore(scoreAr, numPlayers);
            Console.WriteLine("\nAverage Score: {0:F}", averageScore);

            static void DisplayBelowAverage(playerNameAr, scoreAr,numPlayers, averageScore);
            Console.Read();

        }
    }
}

Open in new window

0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 36898426
The description doesn't specify if the arrays must be passed into the methods.  Do you know if you're allowed to use static arrays and variables?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 36898433
Here's a possible setup:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {

        static string[] playerNameAr = new string[100];
        static double[] scoreAr = new double[100];

        public static void Main(string[] args)
        {
            int numPlayers = InputData();
            DisplayPlayerData(numPlayers);
            double averageScore = CalculateAverageScore(numPlayers);
            Console.WriteLine("\nAverage Score: {0:F}", averageScore);
            DisplayBelowAverage(numPlayers, averageScore);

            Console.Write("Press Enter to Quit");
            Console.ReadLine();
        }

        public static int InputData()
        {
            // do while name isn't "Q", store name/score and increment counter
            // return the counter value
        }

        public static void DisplayPlayerData(int numPlayers)
        {
            // iterate over arrays up to "numPlayers" and output
        }

        public static double CalculateAverageScore(int numPlayers)
        {
            // iterate over array up to "numPlayers" and keep running total, return average
        }

        public static void DisplayBelowAverage(int numPlayers, double avg)
        {
            //iterate over array up to "numPlayers" and output those less than the average
        }

    }
}

Open in new window

0
 

Author Comment

by:Michael Reeve
ID: 36898434
Yes, static arrays and variables are allowed. It is a basic example of the use of arrays, not sure why I am struggling with this basic concept.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 36898438
See if you can flesh out my last post...  =)
0
 

Author Comment

by:Michael Reeve
ID: 36898453
You provided an excellent shell and a starting point for me to work through. This is what I needed to get moving in the right direction. Really appreciate it.
0
 

Author Closing Comment

by:Michael Reeve
ID: 36898457
Thank you very much for you help. You provided an excellent starting template. Your comments you provided in each method helped to make it understandable. Thank you!!
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 36898463
Lemme know if you have specific questions implementing it.
0
 

Author Comment

by:Michael Reeve
ID: 36898487
Thanks I will. I appreciate you directing me down the right path. Thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses
Course of the Month11 days, 15 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question