Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

[Newbie question] Can't find the mistake in this simple code?

Why am I getting "error CS1022: Type or namespace definition, or end-of-file expected" for this code? I know I'm looking over something basic... but I've been trying to figure this out for like 45 minutes already.



using System;


namespace test

{

class Program

{

static void Main(string[] args)

{ // What is Num 1 divided by Num 2? Store answer in variable. Then if true tell its true, if not true tell them to write again

Random numberGenerator = new Random ();

int num01 = numberGenerator.Next(1,11);

int num02 = numberGenerator.Next(1,11);


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


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


if (answer == num01 * num02) {


int responseindex = numberGenerator.Next(1,4);

switch (responseindex)

{

case 1:

Console.WriteLine("Yess!");

break;

case 2:

Console.WriteLine("yessssss!");

break;

default:

Console.WriteLine("naais.");

break;

}

}

else {

Console.WriteLine ("No!");




}

}


}

}

}

Best Answer

  • ConsCons Member
    Accepted Answer

    Looks to me like all you need to do is remove the final curly brace at the end of the code. That should do the trick :)!

Answers

Sign In or Register to comment.