Marques Johnston

Greenhorn
+ Follow
since Mar 19, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Marques Johnston

good day all, i am using java greenfoot for the first time to create a canyon bomber/ bomber plane type of game, anyway, i am having a problem with a constructor, could anyone help me,please?
thank you,

here's my code:


oh and when i try to compile this, an error says: invalid method declaration; return type required
12 years ago
Apprecaite the help everyone,
that was really helpful, hopefully as i get used to loops, i will remeber to include the brackets.

Thank you all
12 years ago
Thank you for the welcome.

J Miller, thanks for the help, before you posted this, i reviewed my code and came up with this:



now, the else and the semi-colon after break are underlined, a bit confused as to what to do here?
12 years ago
good day all, i have been having problems trying to construct a while loop, it is my first time and i am clueless as to how to get it to work.
Here are my instructions:
You are to write a complete Java program that plays a simple game. The game simply chooses a
random number between 1 and 100, and then has the user make several attempts at guessing the
number. Here’s the outline of what your program should do:
1. Prompt the user for and read in the number of guesses the user wants at the random number.
2. Generate (but not immediately display) the random number between 1 and 100.
3. As long as the user has not yet guessed the random number and the number of guesses
allowed has not been exceded:
• Prompt the user to enter their next guess at the generated random number.
• If the guess is smaller than the actual random number, print out a message indicating
that the user’s guess is too small.
• If the guess is larger than the actual random number, print out a message indicating
that the user’s guess is too large.
4. If the user succeeded in guessing the random number, then print out a congratulatory
message and tell them how many guesses they took.
5. If the user did not succeed in guessing the random number, the number should be displayed.


This is my code:


When i run this, lets say for 5 guesses, it does this:
How many guesses do you want?5
What is your guess?
56
How many guesses do you want?


when it is actually supposed to do this:

How many guesses do you want? 5
Guess #1: What is your guess? 50
Sorry - your guess is too low.
Guess #2: What is your guess? 75
Sorry - your guess is too high.
Guess #3: What is your guess? 63
Congratulations - you guessed the number!!
It took you 3 guess.


so if anyone could assist me as soon as possible with this, that would be very helpful.

Thank you
12 years ago