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

13»

Comments

  • I did it this way is it right?

    using System;


    namespace My_First___PRO___Program

    {

      class Program

      {

        static void Main(string[] args)

        { 

          double num01; 

          double num02;

          double num03; 


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

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


          if(num01 == 10 ) { 

            Console.WriteLine("Correct!");

          } else {

            Console.WriteLine("Wrong!");

          }

           

          Console.Write("6 / 3 + 8 = ");

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

         

          if(num02 == 10 ) { 

            Console.WriteLine("Correct!");

          } else {

            Console.WriteLine("Wrong!");

          }

           

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

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


          if(num03 == 1 ) { 

            Console.WriteLine("Correct!");

          } else {

            Console.WriteLine("Wrong!");

          }


          Console.ReadKey();

        }   

      }

    }  



  • KurRuppted (F5)


    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)

    {

    // variables

    double answer01;

    double answer02;

    double answer03;


    // problems

    Console.Write("10+9*9: ");

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

    if (answer01 == 91)

    {

    Console.WriteLine("Correct!");

    }

    else

    {

    Console.WriteLine("Incorrect");

    }


    Console.Write("7+9*7-8: ");

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


    if (answer02 == 62)

    {

    Console.WriteLine("Correct");

    }

    else{

    Console.WriteLine("Incorrect");

    }


    Console.Write("9*8-8/2+7: ");

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


    if (answer03 == 75)

    {

    Console.WriteLine("Correct");

    }

    else

    {

    Console.WriteLine("Incorrect");

    }


    // end

    Console.WriteLine("You have finished the math problem quiz thing!");



    Console.ReadKey();

    }

    }

    }

  • I made mine!

    using System;



    namespace Quiz_Game_Math

    {

        class Program

        {

            static void Main(string[] args)

            {

                int answer;

               

                // First problem

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



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



                if (answer == 60) {

                    Console.WriteLine("Correct!");

                } else {

                    Console.WriteLine("Incorrect!");

                }



                // Second problem

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



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



                if (answer == 5) {

                    Console.WriteLine("Correct!");

                } else {

                    Console.WriteLine("Wrong!");

                }



                // Third problem

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



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



                if (answer == 6) {

                    Console.WriteLine("Correct!");

                } else {

                    Console.WriteLine("Wrong!");


                    Console.Write("4+2/3x7(12+33)/3");


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


                       if (answer == 74)

                       {

                           Console.Write("Correct!");

                       }


                        else

                        {

                            Console.Write("Incorrect!");

                        }


                        Console.Write("$5,876 are distributed equally among 26 men.);

                        Console.Write("How much money will each person get?);


                        if (answer == 226)

                        {

                            Console.Write("Correct!");


                        }


                        else

                        {

                            Console.WriteLine("Incorrect!");

                        }





                // Wait before closing

                   Console.ReadKey();

           

        I'm adding more! We're making games, we'll post them here, so hang on with us!

  • I made mine!



    using System;



    namespace Quiz_Game_Math

    {

        class Program

        {

            static void Main(string[] args)

            {

                int answer;

               

                // First problem

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



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



                if (answer == 60) {

                    Console.WriteLine("Correct!");

                } else {

                    Console.WriteLine("Incorrect!");

                }



                // Second problem

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



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



                if (answer == 5) {

                    Console.WriteLine("Correct!");

                } else {

                    Console.WriteLine("Wrong!");

                }



                // Third problem

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



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



                if (answer == 6) {

                    Console.WriteLine("Correct!");

                } else {

                    Console.WriteLine("Wrong!");


                    Console.Write("4+2/3x7(12+33)/3");


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


                       if (answer == 74)

                       {

                           Console.Write("Correct!");

                       }


                        else

                        {

                            Console.Write("Incorrect!");

                        }


                        Console.Write("$5,876 are distributed equally among 26 men.);

                        Console.Write("How much money will each person get?);


                        if (answer == 226)

                        {

                            Console.Write("Correct!");


                        }


                        else

                        {

                            Console.WriteLine("Incorrect!");

                        }





                // Wait before closing

                   Console.ReadKey();

           

       

    Hang around with us because we'll make a game!

  • Here is the code:


    Here is if the user gets it corect:

    Here is if the get it wrong:

    Also thank you Brackeys for the tutorials I enjoy coding with you and the fun challenges.

  • MekseeMeksee Member

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


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


    if (answer == 4){

        Console.WriteLine("Correct!");

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


    Console.Write("7 * 6 / 3 = ");


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


    if (answer2 == 14){

        Console.WriteLine("Correct!");

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


    Console.Write("(4 + 5 * 6) + 2 = ");


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


    if (answer1 == 36){

        Console.WriteLine("Correct!");

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





    Console.ReadKey();

  • overover Member

    int answer;


    //first problem

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


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


    if (answer == 30)

    {

    Console.WriteLine("Correct!");

    }

    else

    {

    Console.WriteLine("Wrong!");

    }

    //second problem


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


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


    if (answer == 2)

    {

    Console.WriteLine("Correct!");

    }

    else

    {

    Console.WriteLine("Wrong!");

    }


    //third problem


    Console.Write("8646678893 + 8899 / 9558 * 758679 + (-4784 * 67784) = ");


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


    if (answer == 8323106606.9959)

    {

    Console.WriteLine("Correct!");

    }

    else

    {

    Console.WriteLine("Wrong!");

    }


    //final problem


    Console.Write("The sum of three numbers is 98.\nThe ratio of the first to the second is 2/3, \nand the ratio of the second to the third is 5/8. The second number is:");

    //don't ask why

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


    if (answer == 30)

    {

    Console.WriteLine("Correct!");

    }

    else

    {

    Console.WriteLine("Wrong!");

    }


    Console.ReadKey();

  • that was fun!

  • AryanAryan Member
    edited May 2023

    i did the challenge-03

    using System;


    namespace Maths_Quiz

    {

        internal class Program

        {

            static void Main(string[] args)

            {

                //Appearance

                Console.Title = "Maths Quiz";

                Console.BackgroundColor = ConsoleColor.DarkGreen;

                Console.ForegroundColor = ConsoleColor.Black;

                //variables

                int ans1 = 11;

                int ans2 = 24;

                int ans3 = 46;

                int ans4 = 44;

                int ans5 = 6;

                int ans6 = 12;

                int ans7 = 14;

                int ans8 = 12;

                int ans9 = 48;

                int ans10 = 126;

                int userInput;

                int correct = 0;

                //Quiz Yes or no

               

                Console.WriteLine("y if you want to do the maths quiz\nn if you don't want to do the maths quiz");

                string yn = Console.ReadLine();

               

                if (yn == "y"){

                    //Quiz

                    Console.Write("Great!\nLets start the quiz.\nThere are 10 maths questions for you to solve.\nHere it Starts!\nThe average of 10, 11 and 12 is ");

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

                    if (userInput == ans1){

                        Console.WriteLine("Correct!");

                        correct = correct + 1;

                    }

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

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

                    if (userInput == ans2){

                        Console.WriteLine("Correct!");

                        correct = correct + 1;

                    }else{

                        Console.WriteLine("Wrong! The answer is 24");

                    }

                    Console.Write("34 + 12 = ");

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

                    if (userInput == ans3){

                        Console.WriteLine("Correct!");

                        correct = correct + 1;

                    }else{

                        Console.WriteLine("Wrong! The answer is 46");

                    }

                    Console.Write("22 * 2 = ");

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

                    if (userInput == ans4){

                        Console.WriteLine("Correct!");

                        correct = correct + 1;

                    }else{

                        Console.WriteLine("Wrong! The answer is 44");

                    }

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

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

                    if (userInput == ans5){

                        Console.WriteLine("Correct!");

                        correct = correct + 1;

                    }else{

                        Console.WriteLine("Wrong! The answer is 6");

                    }

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

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

                    if (userInput == ans6){

                        Console.WriteLine("Correct!");

                        correct = correct + 1;

                    }else{

                        Console.WriteLine("Wrong! The answer is 12");

                    }

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

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

                    if (userInput == ans7){

                        Console.WriteLine("Correct!");

                        correct = correct + 1;

                    }else{

                        Console.WriteLine("Wrong! The answer is 14");

                    }

                    Console.Write("18 + 18 / 3 = ");

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

                    if (userInput == ans8){

                        Console.WriteLine("Correct!");

                        correct = correct + 1;

                    }else{

                        Console.WriteLine("Wrong! The answer is 12");

                    }

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

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

                    if (userInput == ans9){

                        Console.WriteLine("Correct!");

                        correct = correct + 1;

                    }else{

                        Console.WriteLine("Wrong! The answer is 64");

                    }

                    Console.Write("9 * 14 = ");

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

                    if (userInput == ans10){

                        Console.WriteLine("Correct!");

                        correct = correct + 1;

                    }else{

                        Console.WriteLine("Wrong! The answer is 126");

                    }

                    Console.WriteLine("You got " + correct + " out of 10 answers correct!");

                   

                   

                   

                }else if (yn == "n"){

                    //quiz end

                    Console.WriteLine("It's ok if you don't want to do the maths quiz.");

                }


                //wait before closing

                Console.ReadKey();

            }

        }

    }

  • taitai Member
    edited May 2023


  • taitai Member
    edited May 2023

    I know It explodes every time your enter in a string value but eh


                            
Sign In or Register to comment.