Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Created by SharpDevelop.
- * User: 5156395
- * Date: 19/06/2017
- * Time: 10:57
- *
- * To change this template use Tools | Options | Coding | Edit Standard Headers.
- */
- using System;
- namespace Multiplication
- {
- class Program
- {
- public static void Main(string[] args)
- {
- Console.WriteLine ("Hello and welcome to the multiplication program. When you are ready type start or help if you need help.");
- string help = Console.ReadLine(); //This allows the program to recognise if the user has typed help or not
- if (help == "help" || help == "Help") //This runs the help if loop if the user has typed help
- {
- Console.WriteLine ("You will be asked 10 multiplication questions where the answer will be no higher than 100. To answer them type in what you believe the answer to be. After the test is over you will be told how many you got correct. Type start when ready to begin");
- }
- while(true) //This is the while loop for the questions
- {
- string UserInput = Console.ReadLine(); //This allows the program to recognise if the user has typed start or not
- int Correct = 0;
- if(UserInput == "Start" || UserInput == "start") //This runs the multiplication code if the user has typed start
- {
- int Min = 1; //These are the min and max numbers for the random generator
- int Max = 10;
- Random Rnd = new Random(); // This is the random number generator that creats all 20 random numbers
- int Number1 = Rnd.Next(Min,Max);
- int Number2 = Rnd.Next(Min,Max);
- int Number3 = Rnd.Next(Min,Max);
- int Number4 = Rnd.Next(Min,Max);
- int Number5 = Rnd.Next(Min,Max);
- int Number6 = Rnd.Next(Min,Max);
- int Number7 = Rnd.Next(Min,Max);
- int Number8 = Rnd.Next(Min,Max);
- int Number9 = Rnd.Next(Min,Max);
- int Number10 = Rnd.Next(Min,Max);
- int Number11 = Rnd.Next(Min,Max);
- int Number12 = Rnd.Next(Min,Max);
- int Number13 = Rnd.Next(Min,Max);
- int Number14 = Rnd.Next(Min,Max);
- int Number15 = Rnd.Next(Min,Max);
- int Number16 = Rnd.Next(Min,Max);
- int Number17 = Rnd.Next(Min,Max);
- int Number18 = Rnd.Next(Min,Max);
- int Number19 = Rnd.Next(Min,Max);
- int Number20 = Rnd.Next(Min,Max);
- //Question 1
- Console.WriteLine("What is " +Number1+ " X " +Number2+ "?"); //This lets the user see the question
- String A1 = Console.ReadLine();
- int A1int = Convert.ToInt32(A1); //This converts their answer from a string to a int
- if (A1int == Number1*Number2) //This checks to see if the user got the answer right or not
- {
- Console.WriteLine("You are correct"); //This is what happens if they did
- Correct++;
- }
- else
- {
- Console.WriteLine("Better luck next time"); //This is what happens if they didnt
- }
- //Question 2
- Console.WriteLine("What is " +Number3+ " X " +Number4+ "?");
- String A2 = Console.ReadLine();
- int A2int = Convert.ToInt32(A2);
- if (A2int == Number3*Number4)
- {
- Console.WriteLine("You are correct");
- Correct++;
- }
- else
- {
- Console.WriteLine("Better luck next time");
- }
- //Question 3
- Console.WriteLine("What is " +Number5+ " X " +Number6+ "?");
- String A3 = Console.ReadLine();
- int A3int = Convert.ToInt32(A3);
- if (A3int == Number5*Number6)
- {
- Console.WriteLine("You are correct");
- Correct++;
- }
- else
- {
- Console.WriteLine("Better luck next time");
- }
- //Question 4
- Console.WriteLine("What is " +Number7+ " X " +Number8+ "?");
- String A4 = Console.ReadLine();
- int A4int = Convert.ToInt32(A4);
- if (A4int == Number7*Number8)
- {
- Console.WriteLine("You are correct");
- Correct++;
- }
- else
- {
- Console.WriteLine("Better luck next time");
- }
- //Question 5
- Console.WriteLine("What is " +Number9+ " X " +Number10+ "?");
- String A5 = Console.ReadLine();
- int A5int = Convert.ToInt32(A5);
- if (A5int == Number9*Number10)
- {
- Console.WriteLine("You are correct");
- Correct++;
- }
- else
- {
- Console.WriteLine("Better luck next time");
- }
- //Question 6
- Console.WriteLine("What is " +Number11+ " X " +Number12+ "?");
- String A6 = Console.ReadLine();
- int A6int = Convert.ToInt32(A6);
- if (A6int == Number11*Number12)
- {
- Console.WriteLine("You are correct");
- Correct++;
- }
- else
- {
- Console.WriteLine("Better luck next time");
- }
- //Question 7
- Console.WriteLine("What is " +Number13+ " X " +Number14+ "?");
- String A7 = Console.ReadLine();
- int A7int = Convert.ToInt32(A7);
- if (A7int == Number13*Number14)
- {
- Console.WriteLine("You are correct");
- Correct++;
- }
- else
- {
- Console.WriteLine("Better luck next time");
- }
- //Question 8
- Console.WriteLine("What is " +Number15+ " X " +Number16+ "?");
- String A8 = Console.ReadLine();
- int A8int = Convert.ToInt32(A8);
- if (A8int == Number15*Number16)
- {
- Console.WriteLine("You are correct");
- Correct++;
- }
- else
- {
- Console.WriteLine("Better luck next time");
- }
- //Question 9
- Console.WriteLine("What is " +Number17+ " X " +Number18+ "?");
- String A9 = Console.ReadLine();
- int A9int = Convert.ToInt32(A9);
- if (A9int == Number17*Number18)
- {
- Console.WriteLine("You are correct");
- Correct++;
- }
- else
- {
- Console.WriteLine("Better luck next time");
- }
- //Question 10
- Console.WriteLine("What is " +Number19+ " X " +Number20+ "?");
- String A10 = Console.ReadLine();
- int A10int = Convert.ToInt32(A10);
- if (A10int == Number19*Number20)
- {
- Console.WriteLine("You are correct");
- Correct++;
- }
- else
- {
- Console.WriteLine("Better luck next time");
- }
- }
- else
- {
- continue;
- }
- Console.WriteLine("Congratulations you got " +Correct+ " out of 10 correct"); //This tells the user how many questions they got right
- Console.WriteLine("Press any key to exit ...");
- Console.ReadKey(true); // This stops the program from exiting straight away
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement