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

BrackeysBrackeys Administrator
edited June 26 in Announcements

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)
        {
            int answer;
            
            // First problem
            Console.Write("15 + 2 * 2 = ");


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


            if (answer == 60) {
                Console.WriteLine("Correct!");
            } else {
                Console.WriteLine("Wrong!");
            }


            // 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!");
            }


            // Wait before closing
            Console.ReadKey();
        }
    }
}


Comments

  • 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 =>");

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

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

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

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

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

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

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

          Console.ReadKey();

        }

      }

    }

  • EttoYTEttoYT Member

    My answer to the problem:


    using System;
    
    namespace Math_Quiz
    {
        class Program
        {
            static void Main(string[] args)
            {
                int input;
                
                Console.WriteLine("10 * 7 / 2 = ");
    
    
                input = Convert.ToInt32(Console.ReadLine());
    
    
                if (input == 35) {
                    Console.WriteLine("Correct Answer!");
                } else {
                    Console.WriteLine("Wrong Answer!");
                }
    
                Console.Write("12 + 2 * 2 = ");
    
    
                input = Convert.ToInt32(Console.ReadLine());
    
    
                if (input == 16) {
                    Console.WriteLine("Correct Answer!");
                } else {
                    Console.WriteLine("Wrong Answer!");
                }
    
                Console.ReadKey();
            }
        }
    }
    


  • 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...");

                Console.ReadKey();


            }


        }

    }

  • 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?");

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


                  if(q1 == 30) {

                    Console.WriteLine("Correct!");

                }else {

                    Console.WriteLine("Incorrect!");

                }


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

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


                 if(q2 == 100) {

                    Console.WriteLine("Correct!");

                }else {

                    Console.WriteLine("Incorrect!");

                }


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

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


                if (q3 == 16) {

                    Console.WriteLine("Correct!");

                }else {

                    Console.WriteLine("Incorrect!");

                }


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

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


                if (q4 == 92) {

                    Console.WriteLine("Correct!");

                }else {

                    Console.WriteLine("Incorrect!");

                }


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

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


                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

                Console.ReadKey();

            }

        }

    }

Sign In or Register to comment.