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();
}
}
}
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();
}
}
}
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();
}
}
}
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();
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 ();
}
}
}
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.");
using System;
using System.Collections.Generic;
using System.Linq;
namespace MyApp // Note: actual namespace depends on the project name.
{
public class Program
{
public static void Main(string[] args)
{
// Title
Console.Title = "Number of students in class";
// Declaring variable: Number of students
int students;
// User input
Console.Write("How many students are in your class: ");
students = Convert.ToInt32(Console.ReadLine());
// Empty array
string[] names = new string[students];
// User input
Console.WriteLine("Please input the name of your students: ");
for (int i = 0; i < names.Length; i++)
{
names[i] = Console.ReadLine();
}
// Sorting in alphabetical order
Console.WriteLine("\nHere are the names of your students in alphabetical order: ");
Array.Sort(names);
for (int i = 0; i < names.Length; i++)
{
Console.WriteLine((i + 1) + ". " + names[i]);
}
// Wait for input before closing
Console.ReadKey();
}
}
}
I found it quite fun actually. I like these where in the end of the "chapter" you're given something to do. Feels like I learn more that way :D
I did it with a list rather than with a array. so I could specify the amount of students instead of a fixed amount and I thought about adding remove from list. It works, but not flawlessly. Throws me an error when I've removed students.
List<string> students = new List<string>();
Console.Write("How many students are there in your class?: ");
int studentsCount = Convert.ToInt32(Console.ReadLine());
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();
}
}
}
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
Heres my solution for this one. Had a lot of problems with this one lol.
Assignment 5:
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();
}
}
}
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();
}
}
}
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();
}
}
}
Hi everyone, been learning 1 video per day. Really enjoy this task, so I made little bit drama to it.
Here is mine:
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();
}
}
}
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();
}
}
}
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();
}
}
}
Check This
using System;
namespace Again
{
class Program
{
static void Main(string[] args)
{
int totalnum;
Console.Write("Enter the num of students: ");
totalnum = Convert.ToInt32( Console.ReadLine());
string[] names = new string[totalnum];
Console.WriteLine("Enter the students name.");
for (int i = 0; i < totalnum; i++)
{
names[i] = Console.ReadLine();
}
Console.WriteLine("\nHere they are alphabetically");
Array.Sort(names);
for (int i = 0; i < totalnum; i++)
{
Console.WriteLine(names[i]);
}
//To End
Console.ReadKey();
}
}
}
My solution to Challenge5-
using System;
namespace yeet_le_program
{
class Challenge5
{
static void Main(string[] args)
{
Console.Write("How many students are there in your class: ");
int students = Convert.ToInt32(Console.ReadLine());
string[] classA = new string[students];
Console.WriteLine("Enter names: ");
for (int i = 0; i < classA.Length; i++)
{
classA[i] = Console.ReadLine();
}
Console.WriteLine("----------------------- \nArranged alphabetically:");
Array.Sort(classA);
for (int i = 0; i < classA.Length; i++)
{
Console.WriteLine(classA[i]);
}
Console.ReadKey();
}
}
}
Found an easy solution to printing out sorted students again. Without using for loop! 😄
using System;
namespace My_Awesome_Program
{
class Program
{
static void Main(string[] args)
{
//Lists
Console.WriteLine("How many students are in your class?");
int number = Convert.ToInt32(Console.ReadLine());
string[] students = new string[number];
Console.WriteLine("Please input their names: ");
for (int i = 0; i < number; i++)
{
students[i] = Console.ReadLine();
}
Array.Sort(students);
students.ToList().ForEach(i => Console.WriteLine(i.ToString()));
Console.ReadKey();
}
}
}
<code> namespace Code_Relearn_Camp
{
class Program
{
static void Main(string[] args)
{
Console.Write("How many students do you have: ");
int x = Convert.ToInt32(Console.ReadLine());
string[] students = new string[x];
Console.WriteLine("Type in their names: ");
for (int i = 0; i < students.Length; i++)
{
students[i] = Console.ReadLine();
}
Console.WriteLine("Here they are alphabetically by first name: ");
Array.Sort(students);
for (int i = 0; i < students.Length; i++)
{
Console.WriteLine(students[i]);
}
//To stop it closing before we press a key.
Console.ReadKey();
}
}
} <code>
`namespace Code_Relearn_Camp
{
class Program
{
static void Main(string[] args)
{
Console.Write("How many students do you have: ");
int x = Convert.ToInt32(Console.ReadLine());
string[] students = new string[x];
Console.WriteLine("Type in their names: ");
for (int i = 0; i < students.Length; i++)
{
students[i] = Console.ReadLine();
}
Console.WriteLine("Here they are alphabetically by first name: ");
Array.Sort(students);
for (int i = 0; i < students.Length; i++)
{
Console.WriteLine(students[i]);
}
//To stop it closing before we press a key.
Console.ReadKey();
}
}
}`
Here's mine
using System;
namespace Teachers_students
{
class Program
{
static void Main(string[] args)
{
Console.Title = "Class 6B";
int studentcount;
Console.Write("Students in class: ");
studentcount = Convert.ToInt32( Console.ReadLine() );
Console.WriteLine("Input the name of the students: ");
string[] studentsname = new string [studentcount];
for (int i = 0; i < studentcount; i++)
{
studentsname[i] = Console.ReadLine();
}
Console.WriteLine("----------------");
Array.Sort(studentsname);
for (int i = 0; i < studentcount; i++)
{
Console.WriteLine(studentsname[i]);
}
Console.ReadKey();
}
}
}
I found it quite fun actually. I like these where in the end of the "chapter" you're given something to do. Feels like I learn more that way :D
I did it with a list rather than with a array. so I could specify the amount of students instead of a fixed amount and I thought about adding remove from list. It works, but not flawlessly. Throws me an error when I've removed students.
List<string> students = new List<string>();
Console.Write("How many students are there in your class?: ");
int studentsCount = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(studentsCount);
for(int i = 0; i < studentsCount; i++)
{
students.Add(Console.ReadLine());
}
students.Sort();
Console.WriteLine("--------------------------------------");
for(int i = 0;i < studentsCount; i++)
{
Console.WriteLine(students[i]);
}
Console.WriteLine("--------------------------------------");
Console.Write("How many students finished school?: ");
int studentEnd = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Tell us which students have ended their year: ");
for(int j = 0; j < studentEnd; j++)
{
students.Remove(Console.ReadLine());
}
Console.WriteLine("These students has finished their year: ");
Console.WriteLine("\n----------------------------");
for(int k = 0; k < studentEnd; k++)
{
Console.WriteLine(students[k]);
}
Console.ReadKey();
I think this also works
using System;
using System.Collections.Generic;
namespace lala
{
class Program
{
static void Main(string[] args)
{
Console.Title = "Lala";
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine("How many studen in class?");
int studenP = Convert.ToInt32( Console.ReadLine());
string[] classer_name = new string[studenP];
Console.WriteLine("is " + studenP + " studen? Ok~ \n(press enter to contines)");
Console.ReadKey();
Console.WriteLine("What is a " + studenP + " stunden name ?");
List<string> StudenName = new List<string>();
for (int i = 0; i < studenP; i++)
{
StudenName.Add(Console.ReadLine());
//StudenName [i] = Console.ReadLine();
}
Console.WriteLine("---------------------------------");
Console.WriteLine("Here is you class of Studen name?");
for (int i = 0; i < studenP; i++)
{
Console.WriteLine(StudenName[i]);
}
Console.WriteLine("(press enter to contines)");
Console.ReadKey();
Console.WriteLine(" 'end' ");
Console.ReadKey();
}
}
}
Here is mine, thanks.
using System;
namespace new_program
{
class Program
{
static void Main(string[] args)
{
Console.ForegroundColor = ConsoleColor.Blue;
Console.Title = "children in class";
int amount;
Console.WriteLine("how many children are there?");
amount = Convert.ToInt32( Console.ReadLine());
string[] children = new string [amount];
Console.WriteLine("type the names of the " + amount + " children");
for (int i = 0; i <children.Length ; i++)
{
children[i] = Console.ReadLine();
}
Console.WriteLine("-----------------");
Array.Sort(children);
for (int i = 0; i < children.Length; i++)
{
Console.WriteLine(children[i]);
}
Console.ReadKey();
}
}
}
Here is mine (I changed it up a bit)
-------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Learning
{
internal class Program
{
static void Main(string[] args)
{
Console.ForegroundColor = ConsoleColor.Blue;
Console.Title = "Students";
Console.WriteLine("How many students are in your class?");
int numS = Convert.ToInt32(Console.ReadLine());
string[] students = new string[numS];
if (numS == 1)
{
Console.WriteLine("What is the name of your student?");
students[0] = Console.ReadLine();
Console.WriteLine("What color would you like to display on your student?");
Console.WriteLine("Red");
}
else
{
Console.WriteLine("What are the names of your students?");
for (int i = 0; i < numS; i++)
{
students[i] = Console.ReadLine();
}
}
if (numS == 1)
{
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("-----------------");
Console.ForegroundColor = ConsoleColor.Green;
Console.Write("Here is your student in your color: ");
Console.ForegroundColor = ConsoleColor.Red;
Console.Write(students[0]);
}
else
{
Console.WriteLine("Here are your students in alphabetical order: ");
Array.Sort(students);
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("-----------------");
Console.ForegroundColor = ConsoleColor.Green;
for (int i = 0; i < students.Length; i++)
{
double rank = i + 1;
Console.WriteLine(rank + ". " + students[i]);
}
}
Console.ReadKey();
}
}
}
Here is my code:
Here is the outcome:
Console.Write("How many students are there in the class: ");
int studentCount = Convert.ToInt32(Console.ReadLine());
string[] students = new string[studentCount];
Console.WriteLine("Please input the name of the students: ");
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]);
}
Console.ReadKey();
using System;
namespace C_
{
class Program
{
static void Main(string[] args)
{
Console.Write("Enter how many students are in your calass: ");
string[] students = new string[Convert.ToInt32(Console.ReadLine())];
Console.WriteLine("Enter your students names: ");
for (int i = 0; i < students.Length; i++)
{
students[i] = Console.ReadLine();
}
Console.WriteLine("Here there names in order: ");
Array.Sort(students);
for (int i = 0; i < students.Length; i++)
{
Console.WriteLine(students[i]);
}
Console.ReadKey();
}
}
}
using System;
namespace My_awesone_program
{
class Program
{
static void Main(string[] args)
{
Random numberGen1 = new Random();
Random numberGen2 = new Random();
int roll1 = 0;
int roll2 = 1;
int attempts1 = 0;
//int totalroll ;
Console.WriteLine("Press any key to roll the dice");
while (roll1 != roll2)
{
Console.ReadKey();
roll1 = numberGen1.Next(1, 7);
roll2 = numberGen2.Next(1, 7);
Console.WriteLine($"You rolled a {roll1} and a {roll2}");
attempts1++;
}
Console.WriteLine($"It took you {attempts1} attempts to roll the same dice");
//Wait before closing
Console.ReadKey();
}
}
}