Question:
Need help with Java homework, I have started working on it but it has become a huge mess?
eyabb
2012-03-23 11:55:06 UTC
here it is before I ruin it


/*
* Random number generator
*
* Pseudo-code: (pronounced SOO-DOH CODE)
* declare variables
* initialize variables
* generate a random number "r"
* print a startup message/splash screen
*
* print a prompt
* read line
* change line into an int called "g", for example, using Integer.parseInt
* while "g" != "r" number
* if "g" < "r"
* ?
* else
* ?
* add one to guesses taken
* print a prompt
* read line
* change line to guessed int "g" using Integer.parseInt
* end while
*
* print results based on number of guesses
*/

import static java.lang.System.out;
import java.util.Random;
import java.util.Scanner;

public class Main
{
/**
* The random number generated.
*/
static Random randomObject;
static int randomInt;
/**
* A line of input text.
*/
static String line;
/**
* The user's guessed number.
*/
static int guessed;
/**
* The count of the total number of guesses required.
*/
static int guessedCount;
/**
* Connection to standard input (viz., the keyboard)
*/
static Scanner scanner;

public static void main(String[] args)
{
// FOR STUDENT TO COMPLETE
// startup message



// FOR STUDENT TO COMPLETE
// initialize variables
// including generating a random number






// FOR STUDENT TO COMPLETE
// prompt for and read a guess as a String
// and change into an int using guessed = Integer.parseInt(line);




while ( guessed != randomInt ) {
// FOR STUDENT TO COMPLETE
// see pseudo-code







// FOR STUDENT TO COMPLETE
// prompt for and read a guess as a String
// and change into an int using guessed = Integer.parseInt(line);





}

// FOR STUDENT TO COMPLETE
// summarize results







// print exit message
out.println("\n\nThanks for visiting the Numberdini");
}
}
Three answers:
UMM
2012-03-23 13:49:41 UTC
I am very confused on what you are asking but here is the code for a program that is kinda a number generator slot game thingy...





import java.util.Random;

import java.util.Scanner;

import static java.lang.System.out;



public class RandNumGame {

public static void main(String[] args) {

//So I can use random and the scanner

Random rand = new Random();

Scanner inp = new Scanner(System.in);



//Variable for input

int a;

int b;



//Prompting the user

System.out.println("Enter a number from 1-20: ");

a = inp.nextInt();



//Finding the random number

//Add one because we dont want 0

b = rand.nextInt(20) + 1;

//if statements to find if number is correct

if(a != b)

System.out.println("That is incorrect, the correct number was: "+b);

else

System.out.println("Correct");





}

}
?
2016-11-29 13:35:49 UTC
a million. regulation degree + Virgin + pals with human beings at prestigious regulation corporation = warm. 2. go away the guy. If he broke up with you he did you a want. you do no longer want shallow those that are no longer there for you dragging you down. he's probably what replace into feeding your melancholy. seem at it this sort: In 10 years, do you want to be waiting to assert "I had intercourse with somebody", or "i'm making six figures at a valuable regulation corporation and that i very own a corvette". hint: the 2nd. Ditch the loser and flow on mutually with your lifestyles.
?
2012-03-23 12:13:09 UTC
and ur question is...?


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...