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 02 Challenge

Hey everyone!

Here is my solution to the challenge from the C# Tutorial 02 (Variables) video that is out this Sunday.

Have fun with it! 😀

```using System;

namespace My_Awesome_Program
{
class Program
{
static void Main(string[] args)
{
// Declare variables
double num01;
double num02;
double num03;

// Get first number
Console.Write("Input a number: ");

// Get second number
Console.Write("Input a second number: ");

// Get third number
Console.Write("Input a third number: ");

// Calculate and display the average
double result = (num01 + num02 + num03) / 3;
Console.WriteLine("The average of these numbers is " + result);

// Wait before closing
}
}
}

```
«13

• Member

I also did it

```using System;
using System.Collections.Generic;
using System.Text;

namespace cOURSE
{
class Program
{
static void Main(string [] args)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.Title = "Brackeys Average Tutorial";

Console.WriteLine("Give a Number for me to average: ");
Console.ForegroundColor = ConsoleColor.White;

Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Give the second Number for me to average: ");
Console.ForegroundColor = ConsoleColor.White;

Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Give the Third Number for me to average: ");
Console.ForegroundColor = ConsoleColor.White;

int finalNum = num1 + num2 + num3;
finalNum = finalNum / 3;

Console.WriteLine();
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("The Result is "+finalNum);

Console.ForegroundColor = ConsoleColor.White;
}
}
}

```

• Member
edited June 2020

Did I went too far?

```using System;

namespace Brackeys_Cs_Tutorial
{
internal static class Episode2
{
private static void Main(string[] args)
{
// Setting up the Console
Console.BackgroundColor = ConsoleColor.Black;
Console.ForegroundColor = ConsoleColor.Cyan;
Console.Title = "Average";

Console.Write("How many Number do you want to Average: ");
Console.WriteLine();

Console.WriteLine("\nAverage is: " + Average(numbers));

// Stopping Console from instantly closing
}

/// <summary>Asks User to Input some Numbers</summary>
/// <param name="numbers">An Array of Number</param>
{
for (int loop1 = 1; loop1 <= numbers.Length; loop1++)
{
switch (loop1)
{
case 1:
Console.Write("Enter " + loop1 + "st Number: ");
break;
case 2:
Console.Write("Enter " + loop1 + "nd Number: ");
break;
case 3:
Console.Write("Enter " + loop1 + "rd Number: ");
break;
default:
Console.Write("Enter " + loop1 + "th Number: ");
break;
}

}
}

/// <summary>Takes Array of Numbers and Averages them</summary>
/// <param name="numbers">An Array of Number that you want to Average</param>
/// <returns>Returns a Averaged out Number</returns>
private static double Average(double[] numbers)
{
double average = new double();

for (int loop2 = 0; loop2 < numbers.Length; loop2++)
{
average += numbers[loop2];
}

return average / numbers.Length;
}
}
}
```

• Member

Hey there all! Here's my answer to challenge #2...

```using System;

namespace myAwesomePrograms
{
class Average
{
static void Main (string[] args)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.Title = "Skynet";

double x;
double y;
double z;

Console.Write("Input the first number: ");

Console.Write("Input the second number: ");

Console.Write("Input the third number: ");

int avg = (x * y * z)/3;
Console.WriteLine("The average of them is " + avg + " ...");

//Waiting before closing
}
}
}
```
• Member
edited June 2020

• Member

I made this program in phone and by mistake posted it in the challenge 03 but its fine.

using System;

namespace JAIVINs_PROGRAM

{

public static class Program

{

public static void Main()

{

double num02;

double num03;

double num01;

double average;

Console.WriteLine("This is a average calculator enter your number to prceed");

Console.Write("Enter the first number =>");

Console.Write("Enter the second number =>");

Console.Write("Enter the third number =>");

average = (num01 + num02 + num03) / 3;

Console.Write("This is the final result =>" + average );

}

}

}

• Member
edited June 2020

is this ok

• Member

• Member

using System;

namespace Challenge_2

{

class Program

{

static void Main(string[] args)

{

//Variables

double num1;

double num2;

double num3;

double Average;

//--------------------------------------------------------------------------------------------------\\

Console.WriteLine("Enter Three Numbers To Take Out Their Average.\n\n\n");

//---------------------------------------------------------------------------------------------------\\

//Assigning Value To Variables

Console.ForegroundColor = ConsoleColor.Green;

Console.Write("Enter Your First Number: ");

Console.ForegroundColor = ConsoleColor.Cyan;

Console.ForegroundColor = ConsoleColor.Green;

Console.Write("Enter Your Second number: ");

Console.ForegroundColor = ConsoleColor.Cyan;

Console.ForegroundColor = ConsoleColor.Green;

Console.Write("Enter Your third number: ");

Console.ForegroundColor = ConsoleColor.Cyan;

//---------------------------------------------------------------------------------------------------\\

//calculating The Average Of The Numbers

Average = (num1 + num2 + num3) / 3;

Console.ForegroundColor = ConsoleColor.Yellow;

Console.WriteLine("The Average Of The Three Numbers Is: " + Average);

//----------------------------------------------------------------------------------------------------\\

//Wait Before Closing

Console.ForegroundColor = ConsoleColor.Gray;

Console.WriteLine("\n\nPress Any Key To Continue.");

}

}

}

• Member

can Anyone tell me how to upload the code with colors like Brackeys do??

• Member

using System;

namespace _4

{

class Program

{

static void Main(string[] args)

{

Console.Title = "BeanOS#2";

Console.WriteLine("Hi I am Bean2OS. What is your name?");

Console.WriteLine(\$"\nHow are you doing {dyson}");

// you can declare some string and then equate it toa readline so that the console notices you senpai

Console.WriteLine("\nThat is great to hear");

double uno;

double deus;

double tres;

Console.WriteLine("\nI'm going to do some mathematical magic\nready?");

Console.Write(\$"\nCan i get your first number {dyson}: ");

Console.Write(\$"\nCan i get your second number {dyson}: ");

Console.Write(\$"\nCan i get your third number {dyson}: ");

Console.WriteLine(\$"\nThank you for your input {dyson}");

double endgame = (uno*deus*tres)/3;

Console.WriteLine(\$"\nHere is the result of your calculation {endgame}.");

Console.WriteLine("My trick was simple.\nAll I did was take your numbers\nmultiply them \nand find the average");

Console.WriteLine("\nRemember to have a good day and smile.\n Good Day");

}

}

}

• Member

This took me less than 5 minuets to make. I also like to give my projects personality.

using System;

namespace Program_1._1

{

class Program

{

static void Main(string[] args)

{

// This text is useless

Console.Title = "The Mystery Program";

Console.ForegroundColor = ConsoleColor.Cyan;

double num01;

double num02;

double num03;

Console.WriteLine("Welcome to The Mystery Program.\nWhat I do, what I'm named, and what I say may change at any point in time. \nSo \n. \n. \n. \nWhat is your name?");

Console.WriteLine("Hello, " + userName + ", my name is D.O.M. \nShort for Don't Overide Me. \nThis program is a calculator right now. \nI can only average three numbers. \nWhat is the first number you would like?");

Console.WriteLine("You entred " + num01 + "! \nWhat is the second number?");

Console.WriteLine("You entred " + num02 + "\nPlease enter your third number");

Console.WriteLine("You entred " + num03 + "\nYour answer is " + (num01 + num02 + num03) / 3 +"!\nPress any key to close");

}

}

}

• Member
edited June 2020

Here Is Mine

```using System;

namespace myProject_001

{

class Program

{

static void Main(string[] args)

{

// Console

Console.Title = "Project 001";

Console.ForegroundColor = ConsoleColor.Yellow;

Console.WindowHeight = 50;

// User Information

double num001;

double num002;

double num003;

Console.WriteLine("Input Name");

// Calculator Part

Console.Write(username + " Input a number: ");

Console.Write("Input a second number: ");

Console.Write("Input a third number: ");

// Math Symbol

double result = num001 + num002 + num003;

double finalResult = result/3;

Console.ForegroundColor = ConsoleColor.Green;

Console.WriteLine("The result it " + finalResult + "\n Press Any Key To Close The Application");

// Before Closing

}

}

}
```
• Member
edited June 2020

Here's mine, just wanted to specify that the user can now input any amount of averages ;)

using System;

using System.Collections.Generic;

namespace Brackeys_average

{

class Program

{

static void Main(string[] args)

{

List<double> doubles = new List<double>();

Console.Write("Input how many numbers you want to average: ");

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

{

Console.Write("Input a number: ");

}

double length = doubles.Count;

double avg = 0;

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

{

avg += doubles[i];

}

avg /= length;

Console.WriteLine("Your result is: " + avg);

}

}

}

• Member

Can somebody help me post my work pls?

• Member
edited July 2020

is it ok to post it like that? Also is my first time and im 10 years old so pls corect me if im wrong with something

using System;

namespace Primul_program

{

class Program

{

static void Main(string[] args)

{

Console.Title = "Hi";

Console.ForegroundColor = ConsoleColor.Green ;

Console.Write("Wanna see a magic trick?");

double num01;

double num02;

double num03;

Console.Write("Say a number: ");

num01 = Convert.ToDouble ( Console.ReadLine() );

Console.Write("Now another one: ");

num02 = Convert.ToDouble ( Console.ReadLine() );

Console.WriteLine("And another one.");

num03 = Convert.ToDouble ( Console.ReadLine() );

double  result = num01 + num02 + num03 ;

double finalResult = result/3;

Console.WriteLine("So i calculated in a way that I will find the average of these three numbers and the average of them is " + finalResult );

Console.WriteLine("Silly me.I forgot to ask your name.So whats your name?");

Console.WriteLine("I like the name " + userName +" .It is nice.My name is Andrew.");

Console.Write("Sooo...what now?");

Console.Write("Oh i know:a story.");

Console.WriteLine("Uhm.. so lets say that our hero,named(pst, now you say a name)");

Console.WriteLine(heroName + ", I think we can go with that.");

Console.WriteLine("Now say a location.");

Console.WriteLine("Where were we?Oh right.So " + heroName + " is at a place named " + placeName + ".");

Console.WriteLine("Now im gonna end bc I ran out of imagination.");

Console.WriteLine("Bye " + userName + ".See?I did not forget your name.");

//wait before close

}

}

}

• Member
edited July 2020
```using System;
namespace My_awesomest_Program
{
class Program
{
static void Main(string[] args)
{

Console.Write("Enter the first number: ");

Console.Write("Enter the second number: ");

Console.Write("Enter the third number: ");

double avg = (num01+num02+num03)/3;
Console.WriteLine("The average is " + avg + "\nJust press any key");

}

}

}

```

• Member

Sooooo.....

I'm a bit late but....

And i messed around with the script a bit and I had a Calculator and something that you can calculate the average 3 numbers...

So here is my script:

```using System;

{
class Program
{
static void Main(string[] args)
{
//Important: Define everything
string options, validOperator;
double num1, num2, Num1, Num2, Num3;

//Detect what the user whant to do
Console.Title = ("Calculator");
Console.ForegroundColor = ConsoleColor.Blue;
Console.BackgroundColor = ConsoleColor.White;
Console.WriteLine("Calculator or Average");

//If they want the Calculator
if(options == "Calculator"){
//This is why we have eys, right?
Console.ForegroundColor = ConsoleColor.White;
Console.BackgroundColor = ConsoleColor.Black;

//The numbers and operators
Console.WriteLine("Number1:");
Console.WriteLine("Number2:");
Console.WriteLine("Enter a valid operator");

//There are more then 1 oparator, right
if(validOperator == "+"){
Console.WriteLine(num1 + num2);
}
else if(validOperator == "-"){
Console.WriteLine(num1 - num2);
}
else if(validOperator == "/"){
Console.WriteLine(num1 / num2);
}
else if(validOperator == "*"){
Console.WriteLine(num1 * num2);
}

else{
Console.ForegroundColor = ConsoleColor.Green;
Console.BackgroundColor = ConsoleColor.Red;
Console.WriteLine("Invalid Operater");
}
}

//If they want the Average
else if(options == "Average"){
//Colors!
Console.ForegroundColor = ConsoleColor.White;
Console.BackgroundColor = ConsoleColor.Black;

//The Numbers and dividing it though 3 so you have the average
Console.WriteLine("Number1");
Console.WriteLine("Number2");
Console.WriteLine("Number3");
Console.WriteLine((Num1 + Num2 + Num3) / 3);
}

//If someone want to break the rules
else{
Console.ForegroundColor = ConsoleColor.Green;
Console.BackgroundColor = ConsoleColor.Red;
Console.WriteLine("There Is no option called " + options + ".");
}

}
}
}
```

• Member

Im not sure how to post it correctly...

using System;

namespace AMK

{

class Program

{

static void Main(string[] args)

{

double num1;

double num2;

double num3;

Console.ForegroundColor = ConsoleColor.Green;

Console.Write("Zahl einfügen: ");

Console.Write("\nZweite Zahl einfügen: ");

Console.Write("\nDritte Zahl einfügen: ");

double Ergebnis = (num1 + num2 + num3) / 3 ;

Console.ForegroundColor = ConsoleColor.Blue;

Console.WriteLine("\nDer Durchschnitt ist " + Ergebnis);

}

}

}

• Member
edited July 2020

@Hubi and @Victor2111 you can click the "P"-like thing on the left and select "" Quote". There should be a "</> Code Block" under it

```Console.WriteLine("Und da hast du die Farben(There you have it)!")
```
• Member

This is how I did it

using System;

namespace Average

{

class Program

{

static void Main(string[] args)

{

Console.Title = "Average";

Console.ForegroundColor = ConsoleColor.Blue;

Console.WindowHeight = 40;

double num01;

double num02 ;

double num03;

double total;

double result;

Console.WriteLine("Enter a Number :");

Console.WriteLine("Enter another number :");

Console.WriteLine("Enter another number :");

total = num01 + num02 + num03;

result = total/3;

Console.WriteLine("The Average of the three numbers is");

Console.WriteLine(result);

}

}

}

• Member

using System;

namespace Average_Calculator

{

class Program

{

static void Main()

{

double num1;

double num2;

double num3;

double sum;

double average;

string restart;

Console.Title = "Average Calculator";

Console.ForegroundColor = ConsoleColor.Green;

Console.Write("Insert the first number:");

Console.Write("Insert the second number:");

Console.Write("Insert the third number:");

sum = num1 + num2 + num3;

average = sum / 3;

Console.Write("The Average is " + average);

Console.Write("\nPress R to restart: ");

if (string.Equals(restart, "R"))

{

Console.Clear();

Main();

}

if (string.Equals(restart, "r"))

{

Console.Clear();

Main();

}

}

}

}

• Member
edited July 2020

I used a little simpler way :)

also multiplied and used int(32) XD

• Member

using System;

namespace My_awesome_project

{

class Program

{

static void Main(string[] args)

{

double  num1;      //all numbers

double  num2;

double  num3;

double  num4 = 3;

Console.Write("Napiš číslo: ");

num1 = Convert.ToDouble( Console.ReadLine() ); //first

Console.Write("Napiš druhé číslo: ");          //second

Console.Write("Napiš poslední číslo: ");       //third

double  result = num1 + num2 + num3 ;          //result

Console.WriteLine("Tady je výsledek: " + result / num4 );

}

}

}

• Member
edited July 2020

Ye, it was pretty easy. Code:

using System;

namespace VSCODEPROJ

{

class Program

{

static void Main(string[] args)

{

Console.Title = "Average Meter (4 Numbers Edition)";

Console.ForegroundColor = ConsoleColor.Cyan;

Console.WindowHeight = 35;

double no1;

double no2;

double no3;

double no4;

Console.WriteLine("What is the first number???");

Console.WriteLine("What is the second number???");

Console.WriteLine("What is the third number???");

Console.WriteLine("What is the fourth / last number???");

// add how much you want

double result = (no1 + no2 + no3 + no4) / 4;

Console.WriteLine("The average beetween this 4 numbers is " + result);

Console.ForegroundColor = ConsoleColor.Yellow;

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

}

}

}

• Member

This is how I did mine

using System;

namespace Awesome_Program

{

class Program

{

static void Main(string[] args)

{

double num01;

double num02;

double num03;

Console.Write("Input a number: ");

Console.Write("Input a second number ");

Console.Write("Input a third number ");

double result = num01 + num02 + num03;

double average = result / 3;

Console.WriteLine("The average of the numbers is " + average);

// Wait before closing

}

}

}

• Member

using System;

namespace My_First_Code

{

class Program

{

static void Main(string[] args)

{

int num1;

int num2;

int num3;

Console.Write("write number1: ");

Console.Write("write number2: ");

Console.Write("write number3: ");

int result = (num1 + num2 + num3) / 3;

Console.WriteLine("the result is " + result);

// the end

}

}

}

• Member
```using System;

namespace Awesome_Projects
{
class Program
{
static void Main(string[] args)
{
Console.Title = "FRIDAY";

double num01;
double num02;
double num03;

Console.Write("Enter 1st number: ");

Console.Write("Enter 2nd number: ");

Console.Write("Enter 3rd number: ");

double avg = (num01+num02+num03)/3;

Console.WriteLine("The average is: "+ avg);

}
}
}

```
• Member

using System;

namespace _4

{

class Program

{

static void Main(string[] args)

{

Console.BackgroundColor = ConsoleColor.DarkGray;

Console.Title = "Can i still code?";

string yos = "jormagund";

double a;

double b;

double c;

Console.Write("gimme a number any number :");

Console.Write("nexxxxt number:");

Console.Write("nexxxxt number:");

Console.WriteLine("hey i really like this word "+yos);

Console.WriteLine("imma add these numbers ... and do some other stuff widit");

double d = (a+b+c)/3 ;

Console.WriteLine("here's your average"+d);

}

}

}

• Member

Here is my solution to the challenge:

• Member

Double num1;

Double num2;

Double num3;

//Input Number 1

Console.Write("Input no.1: ");

//Input Number 2

Console.Write("Input no.2: ");

//Input Number 3

Console.Write("Input no.3: ");