{
// MATH EQUATION 1
// Writing math equation 1
Console.WriteLine("4 + (5 * 2) = ");
// Player writes answer 1
int answer = Convert.ToInt32(Console.ReadLine());
// Checking if the answer is correct or wrong
if (answer == 14) {
Console.WriteLine("Correct!");
}
else {
Console.WriteLine("Wrong!");
}
// MATH EQUATION 2
// Writing math equation 2
Console.WriteLine("5 + 7x = 19. What is 'x' ?");
// Player writes answer 2
int answer02 = Convert.ToInt32(Console.ReadLine());
// Checking if the answer is correct or wrong
if (answer02 == 2) {
Console.WriteLine("Correct!");
}
else {
Console.WriteLine("Wrong!");
}
// MATH EQUATION 3
// Writing math equation 3
Console.WriteLine("(11 + 2) - (5 * 2) = ");
// Player writes his answer
int answer03 = Convert.ToInt32(Console.ReadLine());
// Checking if the answer is correct or wrong
if (answer03 == 3) {
Console.WriteLine("Correct!");
}
else {
Console.WriteLine("Wrong!");
}
// Wait before closing
Console.ReadKey();
}
}
}
Assignment3: Reduced to 2 from 10 due to text limit.
using System;
namespace C__Assignment3
{
class Program
{
static void Main(string[] args)
{
int result01,result02,result03;
int score = 0;
Console.WriteLine("Welcome to the Basic Mathematic MCQ Quiz");
Console.WriteLine("Q1. What is '5+6-7*8'? \n1. -38\n2. -46\n3. -45\n4. -42\nEnter your choice: ");
result01 = Convert.ToInt32( Console.ReadLine() );
switch(result01){
case 1:
Console.WriteLine("You are incorrect");
break;
case 2:
Console.WriteLine("You are incorrect");
break;
case 3:
Console.WriteLine("You are correct");
score += 5;
break;
case 4:
Console.WriteLine("You are incorrect");
break;
default:
Console.WriteLine("You didnt choose a correct option number.");
break;
}
Console.WriteLine("Q2. What is '2*2-3'? \n1. 1\n2. 4\n 3. -1\n4. -2\n Enter your choice: ");
result02 = Convert.ToInt32( Console.ReadLine() );
switch(result02) {
case 1:
Console.WriteLine("You are correct");
score += 5;
break;
case 2:
Console.WriteLine("You are incorrect");
break;
case 3:
Console.WriteLine("You are incorrect");
break;
case 4:
Console.WriteLine("You are incorrect");
break;
default:
Console.WriteLine("You chose the incorrect option no.");
break;
}
Console.WriteLine("Your score is: " + score +"out of 8");
if(score==10) {
Console.WriteLine("You have aced the test.");
}
else if(score==5) {
Console.WriteLine("You can do better! Keep at it!!");
}
else
{
Console.WriteLine("You need to strengthen your fundamentals. Best of luck next time.");
}
//wait before closing
Console.ReadKey();
}
}
}
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 = "Maths Quiz";
// Declaring the variable Score
int score = 0;
// Quiz 1
Console.WriteLine("Enter a number between the smallest prime number and 4²");
int ans1 = Convert.ToInt32(Console.ReadLine());
if (ans1 > 2 && ans1 < 16){
score = score + 1;
Console.WriteLine("Correct! Your score is now " + score + "/5");
} else {
Console.WriteLine("Wrong! Your score is " + score + "/5");
}
// Quiz 2
Console.WriteLine("What is 22 / 2 * 4?");
int ans2 = Convert.ToInt32(Console.ReadLine());
if (ans2 == 44) {
score = score + 1;
Console.WriteLine("Correct! Your score is now " + score + "/5");
} else {
Console.WriteLine("Wrong! Your score is " + score + "/5");
}
// Quiz 3
Console.WriteLine("What is 9 cube - 2?");
int ans3 = Convert.ToInt32(Console.ReadLine());
if (ans3 == 727){
score = score + 1;
Console.WriteLine("Correct! Your score is now " + score + "/5");
} else {
Console.WriteLine("Wrong! Your score is " + score + "/5");
}
// Quiz 4
Console.WriteLine("Input the age of any teenager");
int ans4 = Convert.ToInt32(Console.ReadLine());
if (ans4 >= 13 && ans4 <=19){
score = score + 1;
Console.WriteLine("Correct! Your score is now " + score + "/5");
} else{
Console.WriteLine("Wrong! Your score is " + score + "/5");
}
// Quiz 5
Console.WriteLine("Write the value of π - e (upto 2 decimal digits)");
double ans5 = Convert.ToDouble(Console.ReadLine());
if (ans5 == 0.43 || ans5 == .43){
score = score + 1;
if (score < 5){
Console.WriteLine("Correct! Your final score is " + score + "/5");
} else if (score == 5){
Console.WriteLine("Congratulations! Your final score is 5/5!");
}
}
else{
Console.WriteLine("Wrong! Your final score is " + score + "/5");
}
// Wait for input before closing
Console.ReadKey();
}
}
}
Comments
I think it's maybe different but it's work !!!
Thanks!
It took me forever to realize that the else if function exists
using System;
namespace Brackeys_Conditions_Challenge
{
class Program
{
static void Main(string[] args)
{
Console.Title = "Brackeys Conditional 2";
Console.ForegroundColor = ConsoleColor.Red;
int answer;
Console.WriteLine("(10 + 5) * 8");
answer = Convert.ToInt32(Console.ReadLine());
if(answer == 120) {
Console.WriteLine("Nice Job");
} else if(answer == 69 || answer == 420){
Console.WriteLine("Your really not funny.");
} else if(answer != 120 || answer != 69){
int roundOff = 120 - answer;
Console.WriteLine("Its fine good try. The answer was 120 and you were " + roundOff + " away from the answer. Good job trying though!");
}
//Wait before closing
Console.ReadKey();
}
}
}
using System;
namespace Toan
{
class Program
{
static void Main(string[] args)
{
Console.Title = "Toan";
Console.WriteLine("1+1+1 =");
int So1 = Convert.ToInt32(Console.ReadLine());
if (So1 >3) {
Console.WriteLine("Wrong!");
}
else if (So1 ==3) {
Console.WriteLine("correct!");
}
else {
Console.WriteLine("Wrong!");
}
Console.WriteLine("2+2+2 =");
int So2 = Convert.ToInt32(Console.ReadLine());
if (So2 >6) {
Console.WriteLine("Wrong!");
}
else if (So2 == 6) {
Console.WriteLine("Correct!");
}
else {
Console.WriteLine("Wrong!");
}
Console.WriteLine("4 * 5 - 20");
int So3 = Convert.ToInt32(Console.ReadLine());
if (So3 >0) {
Console.WriteLine("Wrong!");
}
else if (So3 ==0) {
Console.WriteLine("Correct!");
}
else {
Console.WriteLine("Wrong!");
}
Console.ReadKey();
}
}
}
Yep!
using System;
namespace _6etry4aetdhsrTH
{
class Program
{
static void Main(string[] args)
{
int answer;
int answer2;
double answer3;
//486
Console.WriteLine("10 + 32 * 3 = ");
answer = Convert.ToInt32(Console.ReadLine());
if(answer == 126){
Console.WriteLine("Correct!");
} else {
Console.WriteLine("Wrong!");
}
Console.WriteLine("12 - 3 + 53 * 9");
answer2 = Convert.ToInt32(Console.ReadLine());
if(answer2 == 486){
Console.WriteLine("Correct!");
} else {
Console.WriteLine("Wrong!");
}
Console.WriteLine("74 * 43 - 1.9");
answer3 = Convert.ToDouble(Console.ReadLine());
if(answer2 == 3180.1){
Console.WriteLine("Correct!");
} else {
Console.WriteLine("Wrong!");
Console.ReadKey();
}
}
}
using System;
namespace Toan
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("1+1+1 =");
int So1 = Convert.ToInt32(Console.ReadLine());
if (So1 ==3) {
Console.WriteLine("Correct!");
}
else {
Console.WriteLine("Wrong!");
}
Console.WriteLine("2+2+2 =");
int So2 = Convert.ToInt32(Console.ReadLine());
if (So2 ==6) {
Console.WriteLine("Correct!");
}
else {
Console.WriteLine("Wrong!");
}
Console.WriteLine("4 * 5 - 20");
int So3 = Convert.ToInt32(Console.ReadLine());
if (So3 ==0) {
Console.WriteLine("Correct!");
}
else {
Console.WriteLine("Wrong!");
}
Console.ReadKey();
}
}
}
// My solution to the problem!
using System;
namespace My_Awesome_Program
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Try to get as many as you can");
Console.WriteLine("10 * 10 -10");
double num01 = Convert.ToDouble(Console.ReadLine());
if (num01 < 90 || num01 > 90) {
Console.WriteLine("Incorrect");
}
else if (num01 == 90){
Console.WriteLine("Correct");
}
Console.WriteLine("42 - 8 * 5");
double num02 = Convert.ToDouble(Console.ReadLine());
if (num02 < 2 || num02 > 2 ){
Console.WriteLine("Incorrect");
}
else if (num02 == 2){
Console.WriteLine("Correct");
}
Console.WriteLine("50 / 5 * 10");
double num03 = Convert.ToDouble(Console.ReadLine());
if (num03 < 100 || num03 > 100){
Console.WriteLine("Incorrect");
}
else if (num03 == 100){
Console.WriteLine("Correct");
}
// Wait before closing
Console.ReadKey();
}
}
}
using System;
namespace _7
{
class Program
{
static void Main(string[] args)
{
Console.Title = "Conditions Math Challenge";
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WindowHeight = 20;
int answer;
Console.Write("15 + 5 * 8 = ");
answer = Convert.ToInt32(Console.ReadLine());
if (answer == 28)
{
Console.WriteLine("Correct!");
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Wrong!");
}
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write("18 / 2 + 5 = ");
answer = Convert.ToInt32(Console.ReadLine());
if (answer == 14)
{
Console.WriteLine("Correct!");
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Wrong!");
}
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write("9 * 4 - 5 = ");
answer = Convert.ToInt32(Console.ReadLine());
if (answer == 31)
{
Console.WriteLine("Correct!");
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Wrong!");
}
Console.ReadKey();
}
}
}
Tried to do a space-efficient code 😀
int ans;
//1
Console.ForegroundColor = ConsoleColor.Cyan;
Console.Write("2 * 2 / 2 = ");
ans = Convert.ToInt32(Console.ReadLine());
if (ans == 2 * 2 / 2) //Answer is 2
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Correct!");
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Wrong!");
}
//2
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine("");
Console.Write("5 * 4 / 2 = ");
ans = Convert.ToInt32(Console.ReadLine());
if (ans == 5 * 4 / 2) //Answer is 10
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Correct!");
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Wrong!");
}
//3
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine("");
Console.Write("6 / 2 * 3 / 9 = ");
ans = Convert.ToInt32(Console.ReadLine());
if (ans == 6 / 2 * 3 / 9) //Answer is 1
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Correct!");
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Wrong!");
}
//End
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine("");
Console.WriteLine("That's all lol press any key to exit");
Console.ReadKey();
using System;
namespace c__code
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Answer the question");
Console.WriteLine("20 * 5 + 5 / 2");
int ans = Convert.ToInt32(Console.ReadLine());
if(ans == 100){
Console.WriteLine("Your answer is right.");
}
else{
Console.WriteLine("Your answer is wrong");
}
Console.ReadKey();
}
}
}
My solution:
using System;
namespace test1
{
class Program
{
static void Main(string[] args)
{
int ans;
Console.Write("2 x 6 = ");
ans = Convert.ToInt32(Console.ReadLine());
if (ans == 12)
{
Console.WriteLine("correct");
}
else
{
Console.WriteLine("R u dumb? Thats wrong.");
}
Console.Write("3 x 7 = ");
ans = Convert.ToInt32(Console.ReadLine());
if (ans == 21)
{
Console.WriteLine("correct");
}
else
{
Console.WriteLine("R u dumb? Thats wrong.");
}
Console.Write("11 x 9 = ");
ans = Convert.ToInt32(Console.ReadLine());
if (ans == 99)
{
Console.WriteLine("correct");
}
else
{
Console.WriteLine("R u dumb? Thats wrong.");
}
Console.ReadKey();
}
}
}
Heres my solution!
This is how I did it. Added some colors and threw in a switch, which was mentioned at the end of the video.
using System;
namespace lil_nigs_program
{
class Program
{
private static int answer;
static void Main(string[] args)
{
//First Problem
Console.WriteLine("1 + 1 + 4");
answer = Convert.ToInt32(Console.ReadLine());
if(answer == 6)
{
Console.WriteLine("Correct");
} else {
Console.WriteLine("Wrong!");
//Seconds Problem
Console.WriteLine("10 + 20");
answer = Convert.ToInt32(Console.ReadLine());
if(answer == 30)
{
Console.WriteLine("Correct");
} else {
Console.WriteLine("Wrong!");
//Third Problem
Console.WriteLine ("100 + 30 + 20");
answer = Convert.ToInt32(Console.ReadLine());
if(answer == 150) {
Console.WriteLine("Correct!");
} else {
Console.WriteLine("Wrong");
}
}
}
// Wait before closing
Console.ReadKey();
}
}
}
using System;
namespace První_hra
{
class Program
{
static void Main(string[] args)
{
Console.ForegroundColor = ConsoleColor.Green;
int ans01;
int ans02;
int ans03;
int ans04;
int ans05;
Console.WriteLine("Napíšeme si test z matiky XDD");
Console.WriteLine("150 - 100");
ans01 = Convert.ToInt32(Console.ReadLine());
if(ans01 == 50)
{
Console.WriteLine("Správně");
}
else
{
Console.WriteLine("Špatně");
}
Console.WriteLine("50 - 50");
ans02 = Convert.ToInt32(Console.ReadLine());
if(ans02 == 0)
{
Console.WriteLine("Správně");
}
else
{
Console.WriteLine("Špatně");
}
Console.WriteLine("55 + 154");
ans03 = Convert.ToInt32(Console.ReadLine());
if(ans03 == 209)
{
Console.WriteLine("Správně");
}
else
{
Console.WriteLine("Špatně");
}
Console.WriteLine("254 * 2");
ans04 = Convert.ToInt32(Console.ReadLine());
if(ans04 == 508)
{
Console.WriteLine("Správně");
}
else
{
Console.WriteLine("Špatně");
}
Console.WriteLine("648 / 2");
ans05 = Convert.ToInt32(Console.ReadLine());
if(ans05 == 324)
{
Console.WriteLine("Správně");
}
else
{
Console.WriteLine("Špatně");
}
//Ends the program
Console.ReadKey();
}
}
}
sorry if you dont understand what is there i am from cz.
Assignment3: Reduced to 2 from 10 due to text limit.
I made a maths test take a look
using System;
namespace Program
{
class Program
{
static void Main(string[] args)
{
int answer;
Console.WriteLine("Press any button to continue and press ENTER to give your answer");
Console.ReadKey();
Console.WriteLine("Welcome to the maths test everybody");
Console.ReadKey();
Console.WriteLine("Okay here are your tests.");
Console.ReadKey();
Console.Write("1. 15 - 12 + 3: ");
answer = Convert.ToInt32(Console.ReadLine());
if (answer == 6) {
Console.WriteLine("Correct!");
} else {
Console.WriteLine("Incorrect!");
}
Console.Write("2. (15 + 22 * 3) * 4: ");
answer = Convert.ToInt32(Console.ReadLine());
if (answer == 324) {
Console.WriteLine("Correct!");
} else {
Console.WriteLine("Incorrect!");
}
Console.Write("3. 3 * 9: ");
answer = Convert.ToInt32(Console.ReadLine());
if (answer == 27) {
Console.WriteLine("Correct!");
} else {
Console.WriteLine("Incorrect!");
}
Console.WriteLine("Press any button to pass the test to the teacher.");
Console.ReadKey();
Console.WriteLine("Thanks for the test you can leave now.");
//close the program
Console.ReadKey();
}
}
}
this is my answer.
int answer01;
int answer02;
int answer03;
Console.Write("15 + 2 * 2 = ");
answer01 = Convert.ToInt32(Console.ReadLine());
if(answer01 == 19){
Console.WriteLine("Correct!");
}else{
Console.WriteLine("Wrong!");
}
Console.Write("10 * 7 - 17 =");
answer02 = Convert.ToInt32(Console.ReadLine());
if(answer02 == 53){
Console.WriteLine("Correct!");
}else{
Console.WriteLine("Wrong!");
}
Console.Write("5 + 9 * 4 = ");
answer03 = Convert.ToInt32(Console.ReadLine());
if(answer03 == 41){
Console.WriteLine("Correct!");
}else{
Console.WriteLine("Wrong!");
}
using System;
namespace Math_quiz__Tutorial_3
{
class Program
{
static void Main(string[] args)
{
int correct = 0;
Console.WriteLine("This is a math quiz. You will be quizzed. BEGIN!");
Console.WriteLine("\nWhat is (2 + 6 + 2)/2?");
if(Convert.ToInt32(Console.ReadLine()) == 5)
{
Console.WriteLine("\nCorrect!");
correct = correct + 1;
}
else
{
Console.WriteLine("\nSorry, your wrong!");
}
Console.WriteLine("\nWhat is (3 + 2 + 3 + 9) * 4");
if(Convert.ToInt32(Console.ReadLine()) == 44)
{
Console.WriteLine("\nCorrect!");
correct = correct + 1;
}
else
{
Console.WriteLine("\nSorry, your wrong!");
}
Console.WriteLine("\nYou got " + correct + "/2 answers correct!");
// Don't close until its time.
Console.ReadKey();
}
}
}
My solution:
using System;
namespace MAP
{
class Program
{
static void Main(string[] args)
{
Console.Title = "KRNL";
Console.ForegroundColor = ConsoleColor.DarkGreen;
Console.WindowHeight = 40;
Console.WriteLine("Answer for each equation");
Console.Write("10 + 5 - 4 =");
double answer1 = Convert.ToDouble(Console.ReadLine());
if (answer1 == 11) {
Console.WriteLine("Correct!");
}
else {
Console.WriteLine("Incorrect");
}
Console.Write("10 + 5 * 40 = ");
double answer2 = Convert.ToDouble(Console.ReadLine());
if (answer2 == 600) {
Console.WriteLine("Correct!");
}
else {
Console.WriteLine("Incorrect");
}
Console.Write("40 / 2 + 10 = ");
double answer3 = Convert.ToDouble(Console.ReadLine());
if (answer3 == 30) {
Console.WriteLine("Correct!");
}
else {
Console.WriteLine("Incorrect");
}
// Wait before closing
Console.ReadKey();
}
}
}
//quiz 1 result1
Console.WriteLine("what is 3+3");
double result1 =Convert.ToInt32(Console.ReadLine());
if (result1==6)
{ Console.ForegroundColor=ConsoleColor.Green;
Console.WriteLine("correct answer!");
}
else
{
Console.ForegroundColor=ConsoleColor.DarkRed;
Console.WriteLine("wrong answer");
}
//quiz 2 result2
Console.ForegroundColor=ConsoleColor.White;
Console.WriteLine("what is 3*4");
double result2 =Convert.ToInt32(Console.ReadLine());
if (result2==12)
{
Console.ForegroundColor=ConsoleColor.Green;
Console.WriteLine("correct answer!");
}
else
{
Console.ForegroundColor=ConsoleColor.DarkRed;
Console.WriteLine("wrong answer");
}
//quiz3 result3
Console.ForegroundColor=ConsoleColor.White;
Console.WriteLine("what is 10-3");
double result3 =Convert.ToInt32(Console.ReadLine());
if (result3==7)
{
Console.ForegroundColor=ConsoleColor.Green;
Console.WriteLine("correct answer!");
}
else
{
Console.ForegroundColor=ConsoleColor.DarkRed;
Console.WriteLine("wrong answer");
}
Console.ReadKey();
Console.ForegroundColor=ConsoleColor.Blue;
Console.WriteLine("Thank you,thats it please press enter to close the program.");
Console.ReadKey(); //presskey to close
using System;
namespace Again
{
class Program
{
static void Main(string[] args)
{
string userName;
int age;
int cost;
int sum;
Console.WriteLine("Welcome to AME's math quiz");
Console.Write("Enter your name: ");
userName = Console.ReadLine();
Console.WriteLine("Hello " + userName + " hear you go \nNote: the answers should be in numbers" );
Console.Write("1. What is your age now if you are born in 2000: ");
age = Convert.ToInt32(Console.ReadLine());
if( age == 21 ) {
Console.WriteLine("CORRECT");
} else{
Console.WriteLine("WRONG");
}
Console.Write("2. What is the cost os 12m wire if 1m = 10: ");
cost = Convert.ToInt32(Console.ReadLine());
if( cost == 120 ) {
Console.WriteLine("CORRECT");
} else{
Console.WriteLine("WRONG");
}
Console.Write("3. (2 * 3 + 5)= ");
sum = Convert.ToInt32(Console.ReadLine());
if( sum == 11 ) {
Console.WriteLine("CORRECT");
} else{
Console.WriteLine("WRONG");
}
if( sum == 11 && cost == 120 && age == 21) {
Console.WriteLine("You Won!");
} else{
Console.WriteLine("You Lose!");
}
Console.WriteLine("Thankyou for playing.");
//To End
Console.ReadKey();
}
}
}
This is my Code check it out guys :)
using System;
namespace Variables
{
class Program
{
static void Main(string[] args)
{
//Declaring Variables//
int answer;
//FIRST PROBLEM//
Console.ForegroundColor = ConsoleColor.White;
Console.Write("5 + 3 + 5 = ");
answer = Convert.ToInt32(Console.ReadLine());
if(answer < 13||answer > 13)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Wrong Answer");
}
else
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Correct Answer");
}
//SECOND PROBLEM//
Console.ForegroundColor = ConsoleColor.White;
Console.Write("5 * 5 * 3 = ");
answer = Convert.ToInt32(Console.ReadLine());
if(answer < 75|| answer > 75)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Wrong Answer");
}
else
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Correct Answer");
}
//THIRD PROBLEM//
Console.ForegroundColor = ConsoleColor.White;
Console.Write("10 * 3 + 10 - 6 = ");
answer = Convert.ToInt32(Console.ReadLine());
if(answer < 34|| answer >34)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Wrong Answer");
}
else
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Correct Answer");
}
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("Press any key to exit");
//Wait before Closing//
Console.ReadKey();
}
}
}
using System;
namespace code
{
class Program
{
static void Main(string[] args)
{
Console.Title = "Math?";
Console.Write("Whats is your name?");
string userName = Convert.ToString(Console.ReadLine());
Console.Write("What is 2+2+2+2/2=?\n");
string q3 = Convert.ToString(Console.ReadLine());
if (q3=="16")
{
Console.Write("Good job " + userName +"!");
}
else
{
Console.WriteLine(userName+"I did not expect that from you ");
}
Console.Write("What is (2+2+2+2+=/5=+40)");
string q4 = Convert.ToString(Console.ReadLine());
if (q4=="56")
{
Console.Write("Good job " + userName +"!");
}
else
{
Console.WriteLine(userName+"I did not expect that from you ");
}
Console.Write("What is 2/2/2+62+65+67+67+78+2\n");
string q5 = Convert.ToString(Console.ReadLine());
if (q5=="349")
{
Console.Write("Good job " + userName +"!");
}
else
{
Console.WriteLine(userName+"I did not expect that from you ");
}
Console.ReadLine();
}
}
}
My Solution to Challenge3:
using System;
namespace yeet_le_program
{
class Challenge3
{
static void Main(string[] args)
{
Console.WriteLine("Lets test your math!");
Console.ReadKey();
Console.Write("23x50= ");
int ans1 = Convert.ToInt32(Console.ReadLine());
if(ans1==1150)
{
Console.WriteLine("Correct!");
}
else
{
Console.WriteLine("Wrong :(");
}
Console.WriteLine("42x98= ");
int ans2 = Convert.ToInt32(Console.ReadLine());
if(ans2==4116)
{
Console.WriteLine("Correct!");
}
else
{
Console.WriteLine("Wrong :(");
}
Console.WriteLine("67x69= ");
int ans3 = Convert.ToInt32(Console.ReadLine());
if(ans3==4623)
{
Console.WriteLine("Correct!");
}
else
{
Console.WriteLine("Wrong :(");
}
}
}
}
Here's my answer, with a twist and my own improvements!
using System;
namespace Mini_Quiz_Game
{
class QuizGame
{
static void Main(string[] args)
{
//Console Appearance
Console.Title = "Mini Quiz Game";
//For questions 1 to 3
double num1 = 13;
double num2 = 24;
double num3 = 76;
double num4 = 420;
double num5 = 69;
//Points Counter
int points = 0;
//Question 1
Console.Write(num1 + " + " + num4 + " - " + num5 + " = ");
double question1 = Convert.ToInt32(Console.ReadLine());
double q1Answer = num1 + num4 - num5;
if (question1 == q1Answer) {
points++;
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Correct!, +1 point. Total point/s: " + points);
} else {
points--;
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Wrong, -1 point. Total point/s: " + points);
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine("The correct answer is: " + q1Answer);
}
//Question 2
Console.ForegroundColor = ConsoleColor.White;
Console.Write(num2 + " * " + num3 + " + " + num1 + " = ");
double question2 = Convert.ToInt32(Console.ReadLine());
double q2Answer = num2 * num3 + num1;
if (question2 == q2Answer) {
points++;
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Correct!, +1 point. Total point/s: " + points);
} else {
points--;
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Wrong, -1 point. Total point/s: " + points);
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine("The correct answer is: " + q2Answer);
}
//Question 3
Console.ForegroundColor = ConsoleColor.White;
Console.Write("(" + num1 + " * " + num2 + " + " + num1 + ") / 2 = ");
double question3 = Convert.ToDouble(Console.ReadLine());
double q3Answer = (num1 * num2 + num1) / 2;
if (question3 == q3Answer) {
points++;
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Correct!, +1 point. Total point/s: " + points);
} else {
points--;
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Wrong, -1 point. Total point/s: " + points);
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine("The correct answer is: " + q3Answer);
}
//Question 4
Console.ForegroundColor = ConsoleColor.White;
Console.Write("Who killed Kite from Hunter X Hunter? ");
string question4 = Console.ReadLine();
string q4Answer1 = "Neferpitou";
string q4Answer2 = "Pitou";
if (question4 == q4Answer1 || question4 == q4Answer2) {
points++;
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Correct!, +1 point. Total point/s: " + points);
} else {
points--;
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Wrong, -1 point. Total point/s: " + points);
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine("The correct answer is: " + q4Answer1 + " or " + q4Answer2);
}
//Question
Console.ForegroundColor = ConsoleColor.White;
Console.Write("Bonus Question: Who is your favorite Hunter X Hunter character? ");
string question5 = Console.ReadLine();
string q5Answer = "Feitan";
if (question5 == q5Answer) {
points = points +2;
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Well, mine too! You got a bonus point for that. +2 points for you. Total point/s: " + points);
} else {
points++;
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Oh, nice! You still earned +1 point because this is just a bonus question! Total point/s: " + points);
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine("Anyways, mine is " + q5Answer + "!");
}
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("Well, that's all");
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Your total points is: " + points);
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
}
}
Here is how I did it!
// Math Game
int answer;
//Problem 1
Console.WriteLine("10 + 20 = ?");
answer = Convert.ToInt32(Console.ReadLine() );
Console.ForegroundColor = ConsoleColor.Yellow;
//Answer 1
if(answer == 30) {
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Correct :D");
}
else {
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Wrong >:(");
}
Console.ForegroundColor = ConsoleColor.Yellow;
//Problem 2
Console.WriteLine("10 - 50 = ?");
answer = Convert.ToInt32(Console.ReadLine() );
//Answer 2
if(answer == 40) {
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Correct :D");
}
else {
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Wrong >:(");
}
Console.ForegroundColor = ConsoleColor.Yellow;
//Problem 3
Console.WriteLine("2 * 4 = ?");
answer = Convert.ToInt32(Console.ReadLine() );
//Answer3
if(answer == 16) {
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Correct :D");
}
else {
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Wrong >:(");
}
I also implemented a score system :)