#### 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 03 Challenge

edited June 26

Hey everyone!

Here is my solution to the challenge from the C# Tutorial 03 (Conditions) video that is out soon.

Have fun with it! 😀

```using System;

namespace My_Awesome_Program
{
class Program
{
static void Main(string[] args)
{

// First problem
Console.Write("15 + 2 * 2 = ");

Console.WriteLine("Correct!");
} else {
Console.WriteLine("Wrong!");
}

// Second problem
Console.Write("10 * 2 / 4 = ");

Console.WriteLine("Correct!");
} else {
Console.WriteLine("Wrong!");
}

// Third problem
Console.Write("(4 + 3 + 2 + 1) / 2 = ");

Console.WriteLine("Correct!");
} else {
Console.WriteLine("Wrong!");
}

// Wait before closing
}
}
}

```

• Member
edited June 29

i made this code in my phone to calculate the average.

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

• Member

```using System;

namespace Math_Quiz
{
class Program
{
static void Main(string[] args)
{
int input;

Console.WriteLine("10 * 7 / 2 = ");

if (input == 35) {
} else {
}

Console.Write("12 + 2 * 2 = ");

if (input == 16) {
} else {
}

}
}
}
```

• Member

using System;

namespace VSCODEPROJ

{

class Program

{

static void Main(string[] args)

{

Console.Title = "Math Challenge";

Console.WriteLine("1 x 5 + 2 x 5 = ?");

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

if (firstResult == 15)

{

Console.WriteLine("Correct!");

}

else

{

Console.WriteLine("Incorrect!");

}

Console.WriteLine("5 x 5 + 3 + 7 = ?");

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

if (secondResult == 35)

{

Console.WriteLine("Correct!");

}

else

{

Console.WriteLine("Incorrect!");

}

Console.WriteLine("Test finished. Press any key to continue...");

}

}

}

• Member

This is how I did it!

using System;

namespace Awesome_Program

{

class Program

{

static void Main(string[] args)

{

Console.Title = ("Maths Quiz");

Console.ForegroundColor = ConsoleColor.DarkCyan;

Console.WriteLine("What is 10 x 3?");

if(q1 == 30) {

Console.WriteLine("Correct!");

}else {

Console.WriteLine("Incorrect!");

}

Console.WriteLine("Mass = 10kg, Acceleration = 10 metres per second find the force");

if(q2 == 100) {

Console.WriteLine("Correct!");

}else {

Console.WriteLine("Incorrect!");

}

Console.WriteLine("What is 10 + 2 x 3?");

if (q3 == 16) {

Console.WriteLine("Correct!");

}else {

Console.WriteLine("Incorrect!");

}

Console.WriteLine("What is 60 + 32");

if (q4 == 92) {

Console.WriteLine("Correct!");

}else {

Console.WriteLine("Incorrect!");

}

Console.WriteLine("What is 100 x 2 + 8");

if(q5 == 208) {

Console.WriteLine("Correct!");

}else{

Console.WriteLine("Incorrect!");

}

Console.ForegroundColor = ConsoleColor.Green;

Console.WriteLine("The quiz has been completed! Press any key to do it over!");

//Wait before closing

}

}

}

• Member

This is my solution(please tell me if there's anything I could do to improve it!):

```using System;

namespace Learn_C_
{
class Program
{
static void Main(string[] args)
{
//Changing the settings
Console.Title = "Beef";
Console.ForegroundColor = ConsoleColor.Green;

/*
Challenge: To do a math quiz with 3 questions.
WIL: If, Else, and Else If + Switch Case
*/

//Code
Console.WriteLine("!Welcome to a Simple Math Quiz!");

//Question 1
Console.WriteLine("Q1: 2^2 + 8 * 9:");

{
Console.WriteLine("Correct!");
}
else
{
Console.WriteLine("Incorrect...");
}

//Question 2
Console.WriteLine("Q2: 6 - 4( 5 * 8 ):");

{
Console.WriteLine("Correct!");
}
else
{
Console.WriteLine("Incorrect...");
}

//Question 3
Console.WriteLine("Q3: 11 * (-5)^2:");

{
Console.WriteLine("Correct!");
}
else
{
Console.WriteLine("Incorrect...");
}

//Press key to close
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("***Press any key to exit.***");
}
}
}
```
• Member

easy

using System;

namespace My_First_Code

{

class Program

{

static void Main(string[] args)

{

int ans1;

int ans2;

int ans3;

Console.WriteLine("1+1= ");

if (ans1 == 2)

{

Console.WriteLine("correct");

}

else

{

Console.WriteLine("wrong");

}

Console.WriteLine("2+2= ");

if (ans2 == 4)

{

Console.WriteLine("correct");

}

else

{

Console.WriteLine("wrong");

}

Console.WriteLine("4+4= ");

if (ans3 == 8)

{

Console.WriteLine("correct");

}

else

{

Console.WriteLine("wrong");

}

• Member

My answer to the problem :

using System;

namespace Math_Quiz

{

class Program

{

static void Main(string[] args)

{

Console.Title = "Math Quiz";

// First Question

Console.Write("5 * 3 = ");

Console.WriteLine("Correct!");

} else {

Console.ForegroundColor = ConsoleColor.Red;

Console.WriteLine("Incorrect!");

}

// Second Question

Console.ForegroundColor = ConsoleColor.Green;

Console.Write("10 * 2 / 2 = ");

Console.WriteLine("Correct!");

} else {

Console.ForegroundColor = ConsoleColor.Red;

Console.WriteLine("Incorrect!");

}

// Third Question

Console.ForegroundColor = ConsoleColor.Green;

Console.Write("30 + 15 + 5 = ");

Console.WriteLine("Correct!");

} else {

Console.ForegroundColor = ConsoleColor.Red;

Console.WriteLine("Incorrect!");

}

// wait before closing

Console.ForegroundColor = ConsoleColor.Red;

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

}

}

}

• Member

I am 12 years old and here's my program.

using System;

namespace Conditions

{

class Program

{

static void Main(string[] args)

{

Console.Title = "Math test.";

Console.ForegroundColor = ConsoleColor.White;

Console.Write("1. (10 x 2) / 4? ");

{

Console.ForegroundColor = ConsoleColor.Green;

Console.WriteLine("Correct!");

}

else

{

Console.ForegroundColor = ConsoleColor.Red;

Console.WriteLine("Wrong!");

}

Console.ForegroundColor = ConsoleColor.White;

Console.Write("2. 150 x 5 - 10 / 2? ");

{

Console.ForegroundColor = ConsoleColor.Green;

Console.WriteLine("Correct!");

}

else

{

Console.ForegroundColor = ConsoleColor.Red;

Console.WriteLine("Wrong!");

}

Console.ForegroundColor = ConsoleColor.White;

Console.Write("9 + 1 * 16? ");

{

Console.ForegroundColor = ConsoleColor.Green;

Console.WriteLine("Correct!");

}

else

{

Console.ForegroundColor = ConsoleColor.Red;

Console.WriteLine("Wrong!");

}

}

}

}

• Member
edited July 18

Hi Brackeys,

I am a huge fan of your's.

I am 14 years old and learned coding through your videos. Thanks for so much good content on your youtube channel.

• Member

Hello Brackeys, je suis 14 years old and i am not good in french.

using System;

namespace The_Test_Object

{

class Program

{

static void Main(string[] args)

{

Console.ForegroundColor = ConsoleColor.White;

Console.BackgroundColor = ConsoleColor.Black;

Console.Title = "Morning :)";

//points

int score = 3;

//problem 01

Console.WriteLine("What is the awnser to: 2 * 4 + 9 :"); //17

if(awnser == 17){

Console.ForegroundColor = ConsoleColor.Green;

Console.WriteLine("Good Job");

}

else{

Console.ForegroundColor = ConsoleColor.Red;

Console.WriteLine("Wrong");

score = score - 1;

}

Console.ForegroundColor = ConsoleColor.White;

//problem 02

Console.WriteLine("What is the awnser to: 90 - 18 / 3 :"); //15

if(awnser == 15){

Console.ForegroundColor = ConsoleColor.Green;

Console.WriteLine("Good Job");

}

else{

Console.ForegroundColor = ConsoleColor.Red;

Console.WriteLine("Wrong");

score = score - 1;

}

Console.ForegroundColor = ConsoleColor.White;

//problem03

Console.WriteLine("What is the awnser to: ((29 - 9) / 2 ) * 3 :"); //30

if(awnser == 30){

Console.ForegroundColor = ConsoleColor.Green;

Console.WriteLine("Good Job");

Console.ForegroundColor = ConsoleColor.Green;

Console.WriteLine("Your Finale Score = " + score + "/3");

}

else{

Console.ForegroundColor = ConsoleColor.Red;

Console.WriteLine("Wrong");

score = score - 1;

Console.ForegroundColor = ConsoleColor.Green;

Console.WriteLine("Your Finale Score = " + score + ("/3"));

}

Console.ForegroundColor = ConsoleColor.White;

//Close thingy

Console.ForegroundColor = ConsoleColor.Red;

Console.WriteLine("--Press a key to exit--");

}

}

}

• Member
edited July 18

Hi brackeys,

The code which I uploaded yersterday was not good. So here is the revamped version of the code-

using System;

namespace ConsoleApp2

{

class Program

{

static void Main(string[] args)

{

Console.Title = "Math Problems";

int points = 3;

Console.Write("Question1. 2*8*2*8:");

if (ans == 256)

{

Console.ForegroundColor = ConsoleColor.Green;

Console.WriteLine("Correct");

if (ans != 256)

{

Console.ForegroundColor = ConsoleColor.Red;

Console.Write("Oh no you answered wrong. Try again:");

points = points - 1;

if (ty != 256)

{

Console.ForegroundColor = ConsoleColor.Red;

Console.WriteLine("Oops you answered the question wrong again, you are out.");

}

else if (ty == 256)

{

Console.ForegroundColor = ConsoleColor.Green;

}

}

Console.Write("First Question was easy. Now Question2.5*6*5*6-300:");

if (ans1 == 600)

{

Console.ForegroundColor = ConsoleColor.Green;

}

else if (ans1 != 600)

{

Console.ForegroundColor = ConsoleColor.Red;

Console.WriteLine("Oh no you answered the question wrong. Try again:");

points = points - 1;

if (ty1 != 600)

{

Console.ForegroundColor = ConsoleColor.Red;

Console.WriteLine("Oops you answered the question wrong again, you are out.");

}

else if (ty1 == 600)

{

Console.ForegroundColor = ConsoleColor.Green;

Console.WriteLine("YAY you answered the question right.");

}

}

Console.WriteLine("I bet this will take some time");

Console.Write("256*256:");

if (ans2 == 65536)

{

Console.ForegroundColor = ConsoleColor.Green;

Console.WriteLine("WOW you are really very smart.");

}

else if (ans2 != 65536)

{

Console.ForegroundColor = ConsoleColor.Red;

Console.WriteLine("Oh no you answered it wrong. Try again:");

points = points - 1;

if (ty2 != 65536)

{

Console.ForegroundColor = ConsoleColor.Red;

Console.WriteLine("Oops you answered the question wrong again, you are out.");

}

else if (ty2 == 65536)

{

Console.ForegroundColor = ConsoleColor.Green;

Console.WriteLine("YAY you answered the question right.");

}

}

}

Console.ForegroundColor = ConsoleColor.Cyan;

Console.WriteLine("YAY, you attemped all the problems and your total points were:" + points + "/3.");

}

}

}

• Member

//Hi Brackeys. I have added a simple grading system using Switch-Case. Here is the code-

using System;

namespace Awesome_Projects

{

class Program

{

static void Main(string[] args)

{

Console.Title = "FRIDAY";

int score = 0;

// QUESTION 1

Console.WriteLine("Welcome to the MATH QUIZ. \nHere is your First problem");

Console.Write("10+20 = ");

if(result1 == 30){

Console.ForegroundColor = ConsoleColor.Green;

Console.WriteLine("Correct");

score++;

}else{

Console.ForegroundColor = ConsoleColor.Red;

Console.WriteLine("Wrong");

}

// QUESTION 2

Console.ForegroundColor = ConsoleColor.White;

Console.WriteLine("Here is your Second problem");

Console.Write("999*999 = ");

if(result2 == 998001){

Console.ForegroundColor = ConsoleColor.Green;

Console.WriteLine("Correct");

score++;

}else{

Console.ForegroundColor = ConsoleColor.Red;

Console.WriteLine("Wrong");

}

// QUESTION 3

Console.ForegroundColor = ConsoleColor.White;

Console.WriteLine("Here is your Third problem");

Console.Write("(4+3+2+1)/2 = ");

if(result3 == 5){

Console.ForegroundColor = ConsoleColor.Green;

Console.WriteLine("Correct");

score++;

}else{

Console.ForegroundColor = ConsoleColor.Red;

Console.WriteLine("Wrong");

}

// QUESTION 4

Console.ForegroundColor = ConsoleColor.White;

Console.WriteLine("Here is your Fourh problem");

Console.Write("2/2 = ");

if(result4 == 1){

Console.ForegroundColor = ConsoleColor.Green;

Console.WriteLine("Correct");

score++;

}else{

Console.ForegroundColor = ConsoleColor.Red;

Console.WriteLine("Wrong");

}

// QUESTION 5

Console.ForegroundColor = ConsoleColor.White;

Console.WriteLine("Here is your Fifth problem");

Console.Write("128*789*548*0*896*999 = ");

if(result5 == 0){

Console.ForegroundColor = ConsoleColor.Green;

Console.WriteLine("Correct");

score++;

}else{

Console.ForegroundColor = ConsoleColor.Red;

Console.WriteLine("Wrong");

}

Console.ForegroundColor = ConsoleColor.White;

Console.WriteLine("Your final score is: " + score);

switch(score){

case 0:

Console.WriteLine("F");

break;

case 1:

Console.WriteLine("D");

break;

case 2:

Console.WriteLine("C");

break;

case 3:

Console.WriteLine("B");

break;

case 4:

Console.WriteLine("A");

break;

case 5:

Console.WriteLine("A+");

break;

default:

Console.WriteLine("Default");

break;

}

}

}

}

• Member
edited July 22

Here's my solution :)

```using System;
﻿
namespace _1
{
class Program
{
static void Main(string[] args)
{
//console settings
Console.Title = "Brackeys Tutorials";
Console.ForegroundColor = ConsoleColor.Green;
Console.WindowHeight = 40;

//variables
double calcA = 15 + 2 * 2;
double calcB = 10 * 2 / 4;
double calcC = (4 + 3 + 2 + 1) / 2;

double resultA, resultB, resultC;

//A
Console.Write("15 + 2 * 2 = ");

if (resultA == calcA)
{
Console.WriteLine("Correct");
}
else
{
Console.WriteLine("Wrong");
}

//B
Console.Write("10 * 2 / 4 = ");

if (resultB == calcB)
{
Console.WriteLine("Correct");
}
else
{
Console.WriteLine("Wrong");
}

//C
Console.Write("(4 + 3 + 2 + 1) / 2 = ");

if (resultC == calcC)
{
Console.WriteLine("Correct");
}
else
{
Console.WriteLine("Wrong");
}

}
}
}
```
• Member
edited July 25

Here's my solution :

using System;

namespace Episode_3_qus

{

class Program

{

static void Main(string[] args)

{

int correct = 0;

int worng = 0;

Console.WriteLine("Here's a question: 15 * 2 + 10 = ?");

Console.WriteLine("You have 4 options:");

Console.WriteLine("1. 40  2. 25");

Console.WriteLine("3. 30  4. 50");

int choose;

if (choose == 1)

{

Console.WriteLine("Correct!");

correct++;

}

else

{

Console.WriteLine("You worng!");

worng++;

}

Console.WriteLine("Here's a question: 19 * 2 + 15 = ?");

Console.WriteLine("You have 4 options:");

Console.WriteLine("1. -6  2. 100");

Console.WriteLine("3. 53  4. 77");

if (choose == 3)

{

Console.WriteLine("Correct!");

correct++;

}

else

{

Console.WriteLine("You worng!");

worng++;

}

Console.WriteLine("Here's a question: 100 * 2 + 2 = ?");

Console.WriteLine("You have 4 options:");

Console.WriteLine("1. 203  2. 202");

Console.WriteLine("3. 200  4. 254");

if (choose == 2)

{

Console.WriteLine("Correct!");

correct++;

}

else

{

Console.WriteLine("You worng!");

worng++;

}

Console.WriteLine("\n");

Console.WriteLine("You answered " + correct + " questions correctly");

Console.WriteLine("You made a mistake in " + worng + " questions");

}

}

}

• Member

Hi! If someone wanna execute this program. Do it and let me know how you like it.

• Member
```using System;

namespace Learning_C____Conditions
{
class Program
{
static void Main(string[] args)
{
double ans;

Console.Write("23 + 9 = ");
if(ans == 32) {
Console.WriteLine("Correct!");
} else {
Console.WriteLine("Incorrect!");
}

Console.Write("75 / 15 = ");
if(ans == 5) {
Console.WriteLine("Correct!");
} else {
Console.WriteLine("Incorrect!");
}

Console.Write("7 * 7 = ");
if(ans == 49) {
Console.WriteLine("Correct!");
} else {
Console.WriteLine("Incorrect!");
}

Console.Write("93 - 17 = ");
if(ans == 76) {
Console.WriteLine("Correct!");
} else {
Console.WriteLine("Incorrect!");
}

Console.Write("47.3 + 24.8 = ");
if(ans == 72.1) {
Console.WriteLine("Correct!");
} else {
Console.WriteLine("Incorrect!");
}

Console.WriteLine("\nFarewell!");

// Wait before closing