#### 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 2020

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
}
}
}

```
«13

• Member
edited June 2020

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 2020

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 2020

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 2020

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 2020

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
}
}
}

```
• Member

• Member

using System;

namespace Math

{

class Program

{

static void Main(string[] args)

{

double result;

//Welcom thing:)

Console.WriteLine("Wellcom to the hardest game of all time");

Console.WriteLine("What is 234 x 23");

//the condition thing

{ Console.WriteLine("Congratulation!!");

}

{Console.WriteLine("wrong");

}

Console.WriteLine("What is 25 x 2");

if (result == 50){

Console.WriteLine("Congratulation");

}

else if (result != 50)

{Console.WriteLine("Wrong");

}

Console.WriteLine("What is 23 x 34");

{ Console.WriteLine("Congratulation!!");

}

{Console.WriteLine("wrong");

Console.WriteLine("What is 200 : 2");

{

Console.WriteLine("Congratulation");

}

{

Console.WriteLine("wrong");

}

Console.WriteLine("What is 191 : 91");

{

Console.WriteLine("Congratulation");

}

{

Console.WriteLine("wrong");

}

Console.WriteLine("What is 200 : 20?");

{

Console.WriteLine("Congratulation");

}

{

Console.WriteLine("wrong");

}

Console.WriteLine("What is 392 : 131");

{

Console.WriteLine("Congratulation");

}

{

Console.WriteLine("wrong");

}

Console.WriteLine("What is 392 : 32");

{

Console.WriteLine("Congratulation");

}

{

Console.WriteLine("wrong");

}

Console.WriteLine("What is 392 : 36");

{

Console.WriteLine("Congratulation");

}

{

Console.WriteLine("Well,you done all :)");

}

}

}}}

}

• Member

HERES MINE BOIS!!!

using System;

namespace Conditions

{

class Program

{

static void Main(string[] args)

{

Console.BackgroundColor = ConsoleColor.Black;

Console.ForegroundColor = ConsoleColor.DarkGreen;

Console.Write("1 * 87 = ");

{

Console.WriteLine("Correct!");

}

else

{

Console.WriteLine("Wrong!");

}

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

{

Console.WriteLine("Correct!");

}

else

{

Console.WriteLine("Wrong!");

}

{

Console.WriteLine(" \nYou Win!");

}

{

Console.WriteLine(" \n1/2 Completed!");

}

else

{

Console.WriteLine(" \nYou Failed!");

}

// wait before closing

}

}

}

• Member

found the maths easy so i did a story quest like thing and i enjoyed makeing it alot i enjoy when i learn the code and i make code my self and it works out:)

-----------------------------------------

using System;

namespace C__quize

{

class Program

{

static void Main(string[] args)

{

Console.Write("your in the woods there are 3 paths to exit which do you take. ");

switch (path)

{

case 1:

break;

case 2:

Console.Write("you came second and there are 2 more paths which do you take. ");

switch (paths)

{

case 1:

break;

case 2:

Console.Write("you have exited the woods you wake up and realised your in a simulation and you wonder to your self what is real and you decide to kill your self but instead of dying you forget everthing and get sent back to the woods.");

break;

default:

Console.Write("Thats not a option. ");

break;

}

break;

case 3:

Console.Write("you find a hut and you decide to live there until your old and dead but you soon go crazy and hang your self.The END");

break;

default:

Console.Write("you have exited the woods and you live on your boring ass life knowing thats the most fun you've had.The END");

break;

}

// wait before closing

}

}

}

• Member
edited September 2020

MY SOLUTION HOPE YOU LIKE IT :)

using System;

class HelloWorld {

static void Main() {

Console.Title = "math questions";

Console.Write("Hello\nwhat is 50*20*132: ");

Console.ForegroundColor = ConsoleColor.Green;

Console.WriteLine("correct!");

} else {

Console.ForegroundColor = ConsoleColor.Red;

Console.WriteLine("wrong!");

}

Console.ForegroundColor = ConsoleColor.White;

Console.Write("what is (5*190*2)/2: ");

Console.ForegroundColor = ConsoleColor.Green;

Console.WriteLine("correct!");

} else {

Console.ForegroundColor = ConsoleColor.Red;

Console.WriteLine("wrong!");

}

}

}

• Member

This is my first time using if statement in C#

and....... i think i can understand it pretty well

```using System;

namespace test
{
class Program
{
static void Main(string[] args)
{
//change appearance
Console.Title = "Math Challange";
Console.ForegroundColor = ConsoleColor.Red;
Console.WindowHeight = 40;

Console.Write("12+2/2 = ");
{
}
else
{
}

Console.Write("2/2*1 = ");
{
}
else
{
}

Console.Write("(3+2*2)/7 = ");
{
}
else
{
}

Console.ResetColor();
Console.WriteLine("Press anything to Exit");

//wait before closing
}
}
}
```
• Member

Still an absolutely beginner !

------------------------------------------------------

using System;

namespace MyAwesomeMathQuiz

{

class Program

{

static void Main(string[] args)

{

int A1;

int A2;

int A3;

Console.Write("A1 : 4 * 6 + 5? ");

Console.Write("A2 : 9 * 5- 3? ");

Console.Write("A3 : 10 / 5 * 2? ");

if(A1 == 29)

{

Console.WriteLine("A1 Correct!");

} else {

Console.WriteLine("A1 Wrong!");

}

if(A2 == 42) {

Console.WriteLine("A2 Correct!");

} else {

Console.WriteLine("A2 Wrong!");

}

if(A3 == 4) {

Console.WriteLine("A3 Correct!");

} else {

Console.WriteLine("A3 Wrong!");

}

}

}

}

• Member

using System;

namespace Best_Program

{

class Program

{

static void Main(string[] args)

{

Console.Write("1 + 2 + 2 = ");

{

Console.WriteLine("Correct!");

}

else

{

Console.WriteLine("False!");

}

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

{

Console.WriteLine("Correct!");

}

else

{

Console.WriteLine("False!");

}

Console.Write("10 * 11 + 50 = ");

{

Console.WriteLine("Correct!");

}

else

{

Console.WriteLine("False!");

}

//10 * 2 + 3 = ?

}

}

}

• Member

using System;

namespace apprentissage_c__challenge_3

{

class Program

{

static void Main(string[] args)

{

int res01;

int res02;

int res03;

int res04;

int res05;

Console.Title = "challenge number 03";

Console.WindowHeight = 35;

Console.ForegroundColor = ConsoleColor.White;

Console.WriteLine("Hello friend, we are going to play a game.\ni put equations and you find the correct answer.\nit's easy ? ok let's go !");

Console.WriteLine("15+8/2");

Console.ForegroundColor = ConsoleColor.White;

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

if (res01 == 19)

{

Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine("you got the right answer !");

}

else

{

}

Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("12+3*2-1");

Console.ForegroundColor = ConsoleColor.White;

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

if (res02 == 17)

{

Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine("you got the right answer !");

}

else

{

}

Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("3^3+2");

Console.ForegroundColor = ConsoleColor.White;

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

if (res03 == 29)

{

Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine("you got the right answer !");

}

else

{

}

Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("1+1");

Console.ForegroundColor = ConsoleColor.White;

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

if (res04 == 2)

{

Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine("you got the right answer !");

}

else

{

}

Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("987+654+321");

Console.ForegroundColor = ConsoleColor.White;

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

if (res05 == 1962)

{

Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine("you got the right answer !");

}

else

{

}

if (res01 == 19 && res02 == 17 && res03 == 29 && res04 == 2 && res05 == 1962 )

{

Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("\nall your answers were right, congratulations !");

}

else if (res01 != 19 && res02 != 17 && res03 != 29 && res04 != 2 && res05 != 1962)

{

Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("\nsorry, all your answers were wrong, try harder next time !");

}

else

{

Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("\nsome of your answers were wrong, try to get them all right next time !");

}

}

}

}

• Member

i did a shorter one, because the first one was too long

```using System;

namespace test
{
class Program
{
static void Main(string[] args)
{
int res;

Console.WriteLine("hello, solve the following problems, please.");

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

if (res == 7){
Console.WriteLine("true");
}
else{
Console.WriteLine("false");
}

Console.Write("987+654+321 = ");

if (res == 1962){
Console.WriteLine("true");
}
else{
Console.WriteLine("false");
}

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

if (res == 4){
Console.WriteLine("true");
}
else{
Console.WriteLine("false");
}

}
}
}

```
• Member

This is my solution, but i didn't use curly brackets for the if and else statements.

And it is still correct, Why is this.

• Member

Console.WriteLine(" 12 * 5 / 6 =");

{

Console.WriteLine("Correct!");

}

else

{

Console.WriteLine("Incorrect");

}

Console.WriteLine(" 12 * 5 /20 =");

{

Console.WriteLine("Correct!");

}

else

{

Console.WriteLine("Incorrect");

}

Console.WriteLine(" 12 * 5 /3 =");

{

Console.WriteLine("Correct!");

}

else

{

Console.WriteLine("Incorrect");

}

• Member

I made this a bit too complicated. For some reason, I was thinking that they needed to get the first one correct to get the next one to show up. Silly me.

```using System;

namespace First_Program
{
class Program
{
static void Main(string[] args)
{
//Change the appearance.

Console.Title = "Practice";
Console.ForegroundColor = ConsoleColor.White;
Console.WindowHeight = 40;

// Variables

//First Question

Console.Write("Time to solve some simple math problems. Please enter the numerical answers for the following questions: \n(10*5)/2 = ");

case 25:
//Second Question
Console.Write("That is correct! Next question:\n10*9+26 = ");
case 116:
//Third Question
Console.Write("That is correct! Final question:\n(9/3)*6 = ");
case 18:
Console.Write("That is correct! Great job!");
break;
default:
Console.WriteLine("Unfortunately, that is incorrect.");
break;
}
break;
default:
Console.WriteLine("Unfortunately, that is incorrect.");
break;
}
break;

default:
Console.WriteLine("Unfortunately, that is incorrect.");
break;
}

// Wait before closing.