0
Why this is not working?
3 Answers
+ 3
Several syntax errors and a typo.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SoloLearn
{
    class Program
    {
        static void Main(string[] args)
        {
             Random NumberGenerator = new Random();
             int x = NumberGenerator.Next(1,101);
 	     int y = NumberGenerator.Next(1,101);
 	     Console.WriteLine("What is" + x "+" + y); //<-- missing a + to concatenate x
             int answer = Convert.ToInt32(Console.ReadLine());
 	     if (answer == x + y){
 		int response = NumberGenerator.Next(1,4);
 		switch (response)
 		{
 			case 1; //<-- case uses a colon ':' not a semicolon ';'
 			Console.WriteLine("Answer was Correct");
 			break;
 			case 2; //<-- case uses a colon ':' not a semicolon ';'
 			Console.WriteLine("It was true");
 			break;
 			default; //<-- case uses a colon ':' not a semicolon ';'
 			Console.WriteLine("Your answer. was right");
 			break;
                 // Missing closing curly brace '}' for switch/if
 		}
 		else{
 			int fals = Math.Abs (answer - (x+ y));
 			if (fals < 1){
 				Console.WriteLine("You are so close");
 				}
 		   else if (fals < 10){
    			Console.WriteLine("You are close"); 
    		}
    		else{
    			Console.WriteLind("You can do better"); //<--Typo WriteLine not WriteLind
        }
    }
}
// Missing 2 closing curly braces '}'
Use whitespace and code formatting to help you read your code and make sure you always close your code blocks by lining things up.
Corrected code in next post
+ 2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SoloLearn {
    class Program {
        static void Main(string[] args) {
                Random NumberGenerator = new Random();
                int x = NumberGenerator.Next(1,101);
 	        int y = NumberGenerator.Next(1,101);
 	        Console.WriteLine("What is " + x + " + " + y);
                int answer = Convert.ToInt32(Console.ReadLine());
 	        if (answer == x + y) {
 		    int response = NumberGenerator.Next(1,4);
     		    switch (response) {
         	          case 1:
             			Console.WriteLine("Answer was Correct");
             			break;
         		  case 2:
             			Console.WriteLine("It was true");
             			break;
         		  default:
             			Console.WriteLine("Your answer. was right");
             			break;
     		    }
     		} else {
     			int fals = Math.Abs (answer - (x + y));
     			if (fals < 1) {
     				Console.WriteLine("You are so close");
     			} else if (fals < 10) {
        			Console.WriteLine("You are close");
        		} else {
        			Console.WriteLine("You can do better");
                        }
                }
          }
      }
}
+ 1
Thank you



