c# - The Door Game Random Number Program -
this question exact duplicate of:
i want create program able function using priorities have set in algorithm! user can select random number until specified number found correct answer...it has 1 error @ moment, need improvising solution until compiles correctly..
using system; using system.collections.generic; using system.linq; using system.text; namespace door_game_remade { class program { static void main(string[] args) { int keynum = 5; // int correctnum = 0; int correctkey= 5; int mindoors = 1; int maxdoors = 10; random getdoor = new random(); int door = getdoor.next(mindoors, maxdoors); console.writeline(" please enter key unlock door: {0}", keynum); (int = keynum; <= 10; i++) { return; } enter code here if (keynum == correctkey) { console.writeline("you have unlocked door! great work!!!"); } else { console.writeline("you have incorrect key!"); console.readkey(); console.read(); } } } }
if i'm understanding correctly, take @ this:
static void main(string[] args) { int keynum = 5; int mindoors = 1; int maxdoors = 10; random getdoor = new random(); int correctkey = getdoor.next(mindoors, maxdoors); // correctkey random int between mindoors , maxdoors. //have user enter in number until guess correctkey value. { console.write(" please enter key unlock door: "); keynum = int.parse(console.readline()); //look int.tryparse if have deal non-integer inputs too. if(keynum != correctkey) // if input incorrect, show message. { console.writeline("you have incorrect key! try again."); console.writeline(); } } while(keynum != correctkey); console.writeline("you have unlocked door! great work!!!"); console.read(); }
Comments
Post a Comment