Buy Solved Penn Foster 402594
Project #402594
Your Project
For your first project, you’ll create a simple number-guessing
game. The game will use a for a statement to ask for three
guesses and an if statement to determine if the answer is
right.
Instructions
1. In NetBeans, create a new Java Application project
named NumberGuess. Review Activity 2 for details.
2. In the main() method, add the code to generate a
random number:
int randNum = 0, guessNum = 0;
//Generates a random number from 1 to 10
randNum = new java.util.Random().nextInt(10) + 1;
System. out.println(“I am thinking of a number from
1 to 10”);
3. Using a for loop, ask for three guesses. See pages 23–24
in the textbook for more details. You can use the following
code to ask for a guess:
System. out.print(“Guess? “);
//Wraps the default input in a simple parser
called Scanner
java. util.Scanner scan = new
java. util.Scanner(System.in);
guess um = scan.next(); //Reads the next
command-line int
System. out.println(“You guessed “ + guess um);
4. Using an if statement in the for block, determine
whether random and guess um are equal. See pages
21–23 in the textbook for more details. You can use the
following code if random and guess um are equal:
System. out.println(“You guessed it!”);
break;
5. When you’re finished, the contents of the main() method
should resemble the following:
int randNum = 0, guessNum = 0;
//Generates a random number from 1 to 10
randNum = new java.util.Random().nextInt(10) + 1;
System. out.println(“I am thinking of random number
from 1 to 10”);
for (/* Figure this part out yourself */) {
System. out.print(“Guess? “);
java. util.Scanner scan = new
java. util.Scanner(System.in);
guess um = scan.next();
System. out.println(“You guessed “ +
guess um);
if (/* Figure this part out yourself */) {
System. out.println(“You guessed it!”);
break;
6. Compile and run the project to ensure it works as
expected. To type input, make sure you click in the
Output panel; otherwise, you’ll modify the code.
To submit your project, you must provide the following
two files:
■ NumberGuess.java
■ NumberGuess.class
Want Assistance with the Penn Foster?
Are you a struggling student who struggles to cope with the pressure of taking online tests because of several extraordinary activities? Or, on the other hand, are you having a hard time completing the required tests quickly and earning high grades? Relax; Examshelpers are here to assist you in this circumstance! The IWantOnlineclasshelp.com business is a fantastic top-notch service that you can use right now to improve your future and connect with premium test-taking services on your behalf. We have been offering exceptional assistance to every student who contacted us when they were seeking prompt, dependable, and high-quality services. We can help you with pay someone to take my online exam services on the go, no matter what issues you’re having with the exam or with exam-related issues. The Online class Help question is settled appropriately here rapidly. Simply give us a call or send us an email, and we’ll be there to provide you with expert exam preparation services that are second to none. We also offer a money-back guarantee, so you won’t have to worry about losing anything. Pay now to take a test online.