Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

BRACKEYS - Solution to C# Tutorial 05 Challenge

2»

Comments

  • I did mine a bit different but got the same result, also thx for these tutorials, they've been really helping me out in learning how to code.


    using System;

    using System.Collections.Generic;


    namespace My_Awrsome_Program

    {

        class Program

        {

            static void Main(string[] args)

            {

                Console.Write("How many students are in your class: ");

                int students;

                students = Convert.ToInt32(Console.ReadLine());


                string[] amountOfStudents = new string[students];


                Console.WriteLine("Please name them all: ");

                

                for (int i = 0; i < students; i++)

                {

                    amountOfStudents[i] = Console.ReadLine();

                }

                

                Console.WriteLine("-------------------------");


                Array.Sort(amountOfStudents);

                for (int i = 0; i < students; i++)

                {

                    Console.WriteLine(amountOfStudents[i]);

                }

                


                // Wait before closing

                Console.ReadKey();

            }

        }

    }

  • NIGHT_C0DENIGHT_C0DE Member
    edited March 4

    using System;

    using System.Collections.Generic;


    namespace New_Program_2

    {

        class Program

        {

            static void Main(string[] args)

            {

                Console.WriteLine("How many students do you have in your class: "); 

                int students;

                students = Convert.ToInt32(Console.ReadLine());

                

                string[] AmountofStudents = new string[students];


                Console.WriteLine("Please Name Them all");


                for (int i = 0; i < students; i++)

                {

                    AmountofStudents[i] = Console.ReadLine();

                }


                Console.WriteLine("---------------------------");


                Array.Sort(AmountofStudents);


                for (int i = 0; i < AmountofStudents.Length; i++)

                {

                    Console.WriteLine(AmountofStudents[i]);

                }


               // Waits Before Closing

               Console.ReadKey();

            }

        }

    }




    I am a bit late casue i just joiend brakeys

  • This is mine


    using System;
    
    
    
    namespace My_Awesome_Program
    {
        class Program
        {
            
            static void Main(string[] args)
            {
                Console.WriteLine("How many students do you have: "); 
              int numStudents = Convert.ToInt32(Console.ReadLine()); 
           
           
           string[] students = new string[numStudents]; 
           
            Console.WriteLine("OK! Now who are they:  ");
            for (int i = 0; i < students.Length; i++)
            {
                students[i] = Console.ReadLine();
            }
           
           
           Console.WriteLine("\nHere they are alphabetically:   ");
    
    
           Array.Sort(students);
    
    
           for (int i = 0; i < students.Length; i++)
           {
               Console.WriteLine(students[i]);
           }
           
           
           // Wait Before Closing 
            Console.ReadKey();
           } 
    
    
        }
    }
    
    
    
  • Mo_Mo_ Member

    Heres my solution for this one. Had a lot of problems with this one lol.

     {
     // Getting amount
    
    
    
    
                Console.WriteLine("Enter the amount of students: ");
    
    
    
    
                int amount = Convert.ToInt32(Console.ReadLine());
    
                string[] names = new string[amount];
    
    
    
    
                // Getting names
    
    
    
    
                Console.WriteLine("Please enter the names of the students: ");
    
    
    
    
                for (int i = 0; i < amount; i++)
    
                {
    
                    names[i] = Console.ReadLine();
    
                }
    
                // Printing names
    
                Array.Sort(names);
    
    
    
    
                Console.WriteLine("-----------");
    
                Console.WriteLine("Here they are alphabetically sorted: ");
    
    
    
    
                for (int i = 0; i < amount; i++)
    
                {
    
                     Console.WriteLine(names[i]);
    
                }
    
    
    
    
                // Wait
    
                Console.ReadKey();
    
            }
    
        }
    
    }
    

               

  • using System;
    
    namespace Test
    {
        class Program
        {
            static void Main(string[] args)
            {
                Console.Title = "BRACKEYS THE BEST";
                
                int amount;
                Console.Write("How many students are in your class: ");
                amount = Convert.ToInt32(Console.ReadLine());
                string[] students = new string[amount];
                Console.WriteLine("Please input the names of the students: ");
                for (int i = 0; i < amount; i++)
                {
                    students[i] = Console.ReadLine();
                }
                Console.WriteLine("----------------");
                
                Array.Sort(students);
                for (int i = 0; i < amount; i++)
                {
                    Console.WriteLine(students[i]);
                }
                
                
                
                
                // wait before close
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("\nPress Enter to exit..");
                Console.ReadKey();
            }
        }
    }
    
    


  • NexNex Member

    Assignment 5:

    using System;
    
    namespace C__Assignment5
    {
        class Program
        {
            static void Main(string[] args)
            {
                //Input the value of array size
                Console.WriteLine("Enter the number of students in your class: ");
                int students = Convert.ToInt32(Console.ReadLine());
                string[] class1 = new string[students];
                //Input the values inside the array
                Console.WriteLine("Write the name of the students: ");
    
                for (int i = 0; i < class1.Length; i++)
                {
                    class1[i] = Console.ReadLine();
                }
                //Arrange the array alphabetically:
                Console.WriteLine("\nArranging the students roster alphabetically...");
                Console.WriteLine("------------------------------------------------");
    
                Array.Sort(class1);
    
                for (int i = 0; i < class1.Length; i++)
                {
                    Console.WriteLine(class1[i]);
                }
                //Wait before closing
                Console.ReadKey();
            }
        }
    }
    
  • RysticonRysticon Member

    using System;


    namespace Tutorial

    {

        class Program

        {

            static void Main(string[] args)

            {

                Console.Title = "Challenge By Brackeys!";


                int totalStudents;


                // Amount of students in the class

                Console.WriteLine("How many students are in your class: ");

                totalStudents  = Convert.ToInt32(Console.ReadLine());


                string[] Students = new string[totalStudents];


                // Names of the students

                Console.WriteLine("Please input the names of the students: ");


                for (int i = 0; i < totalStudents; i++)

                {

                    Students[i] = Console.ReadLine();

                }


                // Seperating students and sorting them by name

                Console.WriteLine("--------------------");


                Array.Sort(Students);

                for (int i = 0; i < totalStudents; i++)

                {

                    Console.WriteLine(Students[i]);

                }

                // Manually closing dotnet console

                Console.WriteLine("\nPress any key to exit");

                Console.ReadKey();

            }   

        }    

    }  

  • AkshayAkshay Member
     Console.Write("How many students are in your class: ");
    
    
                int studentCount = Convert.ToInt32(Console.ReadLine());
    
    
                Console.WriteLine("Please input the names of the students: ");
    
    
                string[] students = new string[studentCount];
    
    
                for (int i = 0; i < studentCount; i++)
                {
                    students[i] = Console.ReadLine();
                }
    
    
                Console.WriteLine("--------------");
    
    
                Array.Sort(students);
    
    
                for (int i = 0; i < studentCount; i++)
                {
                    Console.WriteLine(students[i]);
                }
    
    
                // Wait before closing
                Console.ReadKey();
    


Sign In or Register to comment.