jeudi 2 juin 2016

comparing user input to 3 generated random number in java

So i want user to enter 3 numbers between 1-10 then the system will generate 3 random numbers then compare them. if they match one you get $250, match 2 $500. match 3 in order $1000, and $0 for no match.

So far i think i got the generator works (cant actually test it atm) but how do i compare them?

here is the code

import java.util.Random

public class lab3
{
    public static void main(String[] args
    {
        System.out.println("Enter three numbers between 1-10 ");

        System.out.println("Enter first guess: ");
        Int firstGuess= keyboard.nextInt();

        System.out.println("Enter second guess: ");
        Int secondGuess= keyboard.nextInt();

        System.out.println("Enter third guess: ");
        Int thirdGuess= keyboard.nextInt();

        Random rnd= new Random();
        for (int counter = 1; counter<= 3; ++counter) {
            int Lottery = rnd.nextInt(10);
            System.out.print("Generated numbers: " + counter + ": ");
        }




Aucun commentaire:

Enregistrer un commentaire