*MAFIA* Forums
*MAFIA* => Help => Topic started by: *MAFIA* Capsloc on May 24, 2006, 04:15:46 PM
-
ok i need help with this. i didnt know where to post it so here it goes
ok im trying to make a game. well it's a project for school. here is what i have to do .
Write an application that plays "guess the number" as follows: Your application chooses the number to be guessed by selecting a random integer in the range 1 to 1000. The application displays the promp Guess a number between 1 and 1000. The player inputs a first guess. If the player's guess is incorrect, your application should display Too high. Try Again. or Too low. Try again. to help the player "zero in" on the correct answer. The application should prompt the user for the next guess. When the user enters the correct answer, display Congratulation s. You guessed the number! and allow the user to choose wether to play again.
here is what i have so far, not much but hey, so if anyone can help i would really appreciate it.
using System;
public class GuessingGame
{
public static void Main (string[]args)
{
Random randomNumber = new Random();
int mainNumber;
for (int counter = 1; counter <=1; counter++)
{
mainNumber = randomNumber.N ext(1,1001);
}
Console.WriteL ine("Number is set, Guess a number between 1 and 1000");
int guess = Convert.ToInt3 2(Console.ReadLi ne()); //read guessed number
EDIT: oh yeah this is a console application.
-
I may have an old borland app that does just that :p let me look later and if I do you can have the source ;)
-
sounds good boner.
-
Here is the general idea in good ole C/C++. Have fun with that.
void main()
{
int daGuess;
int daNumber = rand() % (1000 - 1) + 1 // Left in this form for a purpose
do
{
cout << "Enter your guess: ";
cin >> daGuess;
cout << endl;
determineCours e(daGuess, daNumber);
} while(daGuess != daNumber);
}
void determineCours e(int aGuess, int goal)
{
if(goal > aGuess)
cout << "Your guess is too low. Try again." << endl;
else if(aGuess > goal)
cout << "Your guess is too high. Try again." << endl;
else
cout << "Congratu-fucking-lations. You've gotten it right." << endl;
}
-
Lol, I made that program on my scientific calculater, its not c++ though but it sure worked nice :P
-
for sure we do. took me 12 guesses to get the correct number.
EDIT: in order to run this you must have the .NET Framework Installed.