Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Homework1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int attCount = 0;
- int attCount2 = 0;
- int maxAttempts = 3;
- int num1 = 5;
- int num2 = 33;
- int num3 = 6;
- int num4 = 40;
- bool isRightAnswer = false;
- bool isRightAnswer2 = false;
- Console.WriteLine("I want to play a game!");
- Console.WriteLine("You must answer these two questions with {0} attempts each!", maxAttempts);
- Console.WriteLine("If you fail...YOU DIE!");
- while (attCount < maxAttempts && isRightAnswer)
- {
- Console.WriteLine("Question 1, Attempt {0} how much is {1} + {2} ?", attCount + 1, num1, num2);
- string answer = Console.ReadLine();
- isRightAnswer = num1 + num2 == int.Parse(answer);
- if (!isRightAnswer)
- {
- Console.WriteLine("you are correct, moving to next question");
- }
- else
- {
- Console.WriteLine("Wrong! you have {0} attempts left", (2 - attCount));
- attCount++;
- }
- }
- while (attCount2 < maxAttempts && !isRightAnswer2)
- {
- Console.WriteLine("Question 2 Attempt {0} how much is {1} + {2} ?", attCount2 + 1, num3, num4);
- string answer2 = Console.ReadLine();
- isRightAnswer2 = num3 + num4 == int.Parse(answer2);
- if (!isRightAnswer)
- {
- Console.WriteLine("You are correct, Your life is safe...until next time...");
- }
- else
- {
- Console.WriteLine("Wrong, you have {0} attempts left", (2 - attCount2));
- attCount2++;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement