How to program in C# challenge #5 – How to make it work both ways?

Updated on January 8, 2018 in General
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
0 on January 8, 2018

So I tried to minimalize the code size needed for the challenge, also only using what was already taught. I also used numberGenerator.Next for an unintended purpose, but it somewhat worked out.

Things is, it only works for values that are higher, and not that are lower.

I figure I can add some more numbers, and then copy and reverse some things so the code also works the other way, but I have a feeling this is solvable right about now and I’m just too bad at math to figure out the solution.



Random numberGenerator = new Random();

int num01 = numberGenerator.Next(1, 11);
int num02 = numberGenerator.Next(1, 11);
int num03 = numberGenerator.Next(1, 11);
int num04 = numberGenerator.Next(-100000, 1000000);

Console.WriteLine(“What is ” + num01 + ” times ” + num02 + “?”);

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

if (answer == num01 * num02)


else if (answer < num01 * num02 + num03)
Console.WriteLine(“So close!”);
else if (answer < num01 * num02 + num04)
Console.WriteLine(“Too far from the answer!”);


  • Liked by