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();
    


  • marimari Member

    I know nobody is still reading these post, but here is my submission


    using System;


    namespace my_awful_program

    {

        class Program

        {

            static void Main(string[] args)

            {

                Console.Title = "Skynet";

                Console.ForegroundColor = ConsoleColor.Green;

                Console.WindowHeight = 40;


                int numStudents = 0;


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

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


                string[] studentsName = new string[numStudents];

                

                Console.WriteLine("What are their names?");


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

                {

                    studentsName[i] = Console.ReadLine();

                }


                Array.Sort(studentsName);

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


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

                {

                    Console.Write("\n" + studentsName[i]);

                }



                Console.ReadKey();

            }

        }

    }

  • Matija8Matija8 Member

    Here is mine to !




    using System;

    using System.Collections.Generic;


    namespace NOVA_PROGRAMERSKA_TRAKA

    {

        class Program

        {

            static void Main(string[] args)

            {

                Console.ForegroundColor = ConsoleColor.Green;

                

                Console.WriteLine("How many students are there? ");

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


                string[] Students = new string[students];


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

                {

                    Students[i] = Console.ReadLine();

                }

                Console.WriteLine("                                                     ");


                Console.WriteLine("Here there go a,b,c....");


                Array.Sort (Students);


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

                {

                    Console.WriteLine(Students[i]);

                }






                Console.ReadKey();

            }

        }

    }

  • isnxsnisnxsn Member

    Hi everyone, been learning 1 video per day. Really enjoy this task, so I made little bit drama to it.

    Here is mine:


    namespace Learn_C_
    {
        class Program
        {
            static void Main(string[] args)
            {
         
    
                Console.Write("How many students in your class: ");
    
                int stuNum = Convert.ToInt32(Console.ReadLine());
    
                Console.WriteLine("\nPlease write their name!");
    
                string[] studentName = new string[stuNum];
    
                for (int i = 0; i < stuNum; i++)
                {
                    studentName[i] = Console.ReadLine();
                }
    
                Console.WriteLine("----------------");
    
                Console.WriteLine("Here is your students names in order:");
    
                Array.Sort(studentName);
    
                for (int i = 0; i < stuNum; i++)
                {
                    Console.ReadKey();
                    int rank = i + 1;
                    Console.WriteLine(rank + ". " + studentName[i]);
                }
    
                Console.WriteLine("\nWell done!");
    
    
                // Wait before closing
                Console.WriteLine("\nPress any key to exit.", Console.ForegroundColor = ConsoleColor.Red);
                Console.ReadKey ();
            }
        }
    }
    


  • using System;

    using System.Collections.Generic;


    namespace C__test

    {

        class Program

        {

            static void Main(string[] args)

            {

                //custom console

                Console.ForegroundColor = ConsoleColor.Yellow;

                Console.Title = "Arrays";


                //declare vars

                int numberOfKids;

                int sortingNum = 1;

                //start

                Console.WriteLine("how many kids are in your class?");

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

                

                string[] kidsNames = new string[numberOfKids];


                Console.WriteLine("type your kids name");

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

                {

                    kidsNames[i] = Console.ReadLine();

                }


                Array.Sort(kidsNames);

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

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

                {


                    Console.WriteLine(sortingNum + ". " + kidsNames[i] );

                    sortingNum++;

                }


                // wait till key enter 

                Console.ReadKey();

                

            }

        }

    }

  • LordA239LordA239 Member

    I know I'm a little late but here is my code

    using System;


    namespace bsw

    {

        class Program

        {

            static void Main(string[] args)

            {

                //unnecessary code

                Console.ForegroundColor = ConsoleColor.Magenta;

                Console.Title = "I Love Brackeys!";


                //actual code

                int number;


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

                number = Convert.ToInt16(Console.ReadLine());


                string[] students = new string[number];


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

                {

                    int place = i + 1;

                    Console.WriteLine("Enter person " + place);

                    students[i] = Console.ReadLine();

                }


                Console.WriteLine("\nThank you, Now here are the people you entered in alphabetical order:");

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


                Array.Sort(students);


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

                {

                    int pos = i + 1;

                    Console.WriteLine(pos + ". " + students[i]);

                }


                Console.WriteLine("Press any key to exit");

                Console.ReadKey();

                

            }

        }

    }

  • NickTheGreekNickTheGreek Member
    edited July 24

    using System;


    namespace New_folder

    {

        class Program

        {

            static void Main(string[] args)

            {

               Console.WriteLine("How many students do U got?"); 

               int numberOFstudents = Convert.ToInt32(Console.ReadLine());


              

               string[] students = new string [numberOFstudents];


             

               Console.WriteLine("Input the names of your students");


             

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

               {

                 Console.WriteLine("NAME:  ");

                 students[i] = Console.ReadLine();

               }


               Array.Sort(students);


               

               Console.WriteLine("\n\nHere they are alphabetically");


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

               {

                   Console.WriteLine(students[i]);

               }


               Console.ReadKey();

                

            }

        }


    }

  • My original attempt didn't work. I was trying to use an "and" (&&) statement in the "While" to check that the attempts were not at "0" as when the program initially runs both roll1 and roll2 were set to start at "0" and already considered "==".

    I did next attempt the solution to just change the roll2 to just start at 1 vs 0. However I am curious if my first solution would work and I had just missed a step.

    My first attempt (didn't work):


     Random numberGen = new Random();

                  int roll1 = 0;

                  int roll2 = 0;

                  int attempts = 0;

                Console.WriteLine("Press enter to roll the dice.");


                while(roll1 != roll2 && attempts >= 1)

                 {

                    Console.ReadKey();

                    roll1 = numberGen.Next(1, 7);

                    roll2 = numberGen.Next(1, 7);

                    Console.WriteLine("die 1: " + roll1);

                    Console.WriteLine("die 2: " + roll2);

                    Console.WriteLine(" ");

                    attempts++;

                }

                Console.WriteLine("It took you " + attempts + " attempts to roll doubles.");


                //wait

                Console.ReadKey();

            }

        }

    }

Sign In or Register to comment.