I'm sorry if my question seems easy or dumb to some of you. I'm only a beginner in the programming world and I'm self-learning multiple programming languages so I have no one to consult.
I'm supposed to write this program:
Create a console project. Add a C# class named TerminalSort. Within TerminalSort, create 2 static functions GenerateRandomData and Sort. GenerateRandomData should take in an integer parameter and return a list of random numbers containing the requested number of elements. Sort should accept a list of integers as a parameter and return back the list sorted by terminal digit. The console project should prompt the user for a number, generate random data based on that number, and then print out the sorted list to the console.
This is what I wrote so far and I'm currently stuck. Any help would be appreciated. Thank you in advance.
namespace Project1
{
public static class TerminalSort
{
static int GenerateRandomData()
{
Console.Write("Enter a number: ");
string userInput1 = Console.ReadLine();
int number = Convert.ToInt32(userInput1);
for (int i=0; i < number; i++)
{
Random random = new Random();
Console.Writeline(random);
}
}
static void Sort()
{
for (int i = 0; i < 5; i++)
{
Console.Write("Enter a number: ");
string userInput2 = Console.ReadLine();
int number2 = Convert.ToInt32(userInput1);
}
}
static void Main(string[] args)
{
System.Console.WriteLine(GenerateRandomData());
System.Console.ReadKey();
}
}
}
Again, I apologize if the question seems dumb or too easy to some of you.
Aucun commentaire:
Enregistrer un commentaire