60 487
Assignments Done
98,1%
Successfully Done
In April 2018

# Answer to Question #73857 in C# for Collins Biwott

Question #73857
A program is required for a computer game. The user keys in the number of rounds he wishes to play.
For each round the user enters his lucky number. The program takes the number and divides it with a
secret number. If the remainder of the division is zero, it is considered a draw for the round and the total
score is incriminated by 1. Otherwise if it is any other even number, it is considered a win for the round
and the total score is incremented by 3. However if it is an odd number, it is considered a loss for the
round and the total score is decremented by 3. This is done until he completes his rounds. He wins if the
total score at the end is a positive number. Write a C# program to accomplish this.
Expert's answer
using System;

namespace Answer
{
class Program
{
public static void Main(string[] args)
{
Random random = new Random(0);
int num;
int Score = 0;
int RoundCount = 0;
int SecretNum = random.Next(0,10);
RestartGame:
Console.Write("Enter The Round Count: ");
try
{
RoundCount = Convert.ToInt32(Console.ReadLine());
if (RoundCount < 0)
{
Console.WriteLine("The number is not supported");
goto RestartGame;
}
}catch(FormatException)
{
Console.WriteLine("You can only enter numbers");
goto RestartGame;
}
for(int i = 0; i < RoundCount;i++)
{
Console.Write("Enter The lucky number: ");
try
{
num = Convert.ToInt32(Console.ReadLine());
}
catch (FormatException)
{
Console.WriteLine("You can only enter numbers");
goto RestartGame;
}

if (num % SecretNum == 0)
{
Console.WriteLine("Draw !!!");
Score++;
} else if ((num % Score) % 2 == 0)
{
Console.WriteLine("You Won !!!");
Score += 3;
} else
{
Console.WriteLine("You lose :-( ");
Score -= 3;
}

if (Score > 0)
Console.WriteLine("You won the game !!! You score: " + Score);
else
Console.WriteLine("You lost the game (( You score: " + Score);
Console.ReadKey();
}
}
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

#### Comments

No comments. Be first!

Submit