Code and test see the java api documentation math

This preview shows page 2 - 3 out of 3 pages.

Code and Test : See the Java API documentation (Math class or Random class) for details on how to generate a random number. Make sure that the integers generated are random numbers between 0 and 9 (inclusive) and that they do not repeat (i.e., they are different from each other). [Hint: When using interactions to test your class, you can use the Up-Arrow to avoid retyping previously entered interactions.] NumberGuessingApp.java Requirements: For each new game, the program creates an instance of the Number class, accepts the user’s guess (entered as four numbers separated by spaces), compares the user’s numbers to the numbers generated by the Number class, and then prints out useful information for user’s next guess. Design: NumberGuessingApp.java contains one main method and one supporting method called compareNums. The compareNums method accepts a Scanner object and returns no value. Note that the Scanner object passed in should be the one you declared in main for System.in to read input. In this method, a new number combination (an instance of the Number class) is created to start a new game. In a while statement, do the following: prompt user to input his/her four number guess, compare this combination to the number combination generated in Number class; print out the information about how many numbers of the four are correct and in the correct position, and print how many of the four number are correct but in the wrong position. Continue prompting the user to guess until the user gets the correct answer or until the user enters in “key” or “end” to end the game and see the correct answer. Note that non-numeric input from the user should not be case-sensitive (e.g., both Y or y should be acceptable).
Image of page 2

Subscribe to view the full document.

Image of page 3
You've reached the end of this preview.
  • Fall '07
  • CROSS
  • Subroutine, Randomness, wrong position, Web-CAT

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern