I have some code that I will post in the comments that I need help fixing some errors. If anyone could help that would be fucking dope. I have been working on this shit for hours and my brain is turning into dog shit at this point. Thanks fags
Help With code
Other urls found in this thread:
learncs.org
codereview.stackexchange.com
pastebin.com
twitter.com
static void Main(string[] args)
{
int selection;
int[] scores = new int[0];
do
{
userMenu;
if (selection == 1)
{
selectionOne;
}
else if (selection == 2)
{
selectionTwo;
}
else if (selection == 3)
{
selectionThree;
}
}
while (selection != 4);
}
public static int userMenu()
{
Console.WriteLine("________Menu________");
Console.WriteLine("1) enter scores");
Console.WriteLine("2) list scores");
Console.WriteLine("3) calculate statistics");
Console.WriteLine("4) exit");
Console.WriteLine("_____________________");
Console.WriteLine("Make a selection (1-4)");
return selection = Convert.ToInt32(Console.ReadLine());
}
public static int selectionOne()
{
Console.WriteLine("How many scores do you want to enter?");
int scoreCount = Convert.ToInt32(Console.ReadLine());
scores = new int[scoreCount];
for (int i = 0; i < scores.Length; i++)
{
Console.WriteLine("Enter a score:");
return scores[i] = Convert.ToInt32(Console.ReadLine());
}
}
public static int selectionTwo()
{
Console.WriteLine("___Scores___");
foreach (int score in scores)
{
Console.WriteLine(score);
}
Console.WriteLine("_____________");
}
public static int selectionThree()
{
int low = 100;
int high = 0;
int sum = 0;
foreach (int score in scores)
{
sum = sum + score;
if (score > high)
{
high = score;
}
if (score < low)
{
low = score;
}
}
Console.WriteLine("___Statistics___");
Console.WriteLine("Low: " + low);
Console.WriteLine("High: " + high);
Console.WriteLine("Average: " + (sum / scores.Length));
Console.WriteLine("_________________");
}
}
}
boomp. If someone would help me Id zuck ya dik
bomop
bumppppp
bamp
if (selection == 1)
{
selectionOne;
}
Either assign a value to a variable, or call a function. You are doing neither.
Also:
For your "enter scores", the function should not return anything, as the array is global.
I am trying to call the method there. Im new to methods. What am I doing wrong?
>What am I doing wrong?
You did not read the chapter on functions.
Try:
selectionOne();
Not sure if I can help right this second but if you tell me which programming language this is, I'm a quick learner.
c#
we dont have a book bruh
Here you go:
learncs.org
I understand it for the most part. I just need help with assigning the actions and making sure the scope is right.
no one is getting they dik zuck yet
ay i never wrote in C# but i know ur pain all too well so have a bump fellow brogrammer
ty sendin them dik zucks
bump plz someone help. I would be forever greatful
bump
BOOOMP
bump2
I was going to post the fixed version, but your incessant bumping is ridiculous
just trying to keep the thread alive
Ill post on here as well. Thank you.
pastebin.com
Please stop posting
note that the codereview SE site is not mainly for fixing errors. it's for improving your code to be maintainable, thus in effect making errors in your code easily detected
>he doesn't use linq
>laughing .NET developer
[code[ int low = scores.Min();
int high = scores.Max();
int sum = scores.Sum();
Console.WriteLine("___Statistics___");
Console.WriteLine("Low: " + low);
Console.WriteLine("High: " + high);
Console.WriteLine("Average: " + (sum / scores.Length));
Console.WriteLine("_________________");[/code]