Java Code Revision

import java.util.Scanner;

public class Pennies {

public static int generateTicketNumber(int min, int max) {

    int range = (max - min) + 1;

    return (int)(Math.random() \* range) + min;

}



public static void main(String\[\] args) {

    // TODO Auto-generated method stub

    int human\_penny;

    int computer\_penny;





    Scanner input = new Scanner(System.in);



    System.out.println("Enter your number of Pennies");

    human\_penny = input.nextInt();



    System.out.println("Enter computer's number of Pennies");

    computer\_penny = input.nextInt();



    System.out.println("Human Penny is before: "+human\_penny);

    System.out.println("Computer Penny is before: "+human\_penny);







    while(true) {


        int coin\_human = generateTicketNumber(1,2);

        int coin\_computer = generateTicketNumber(1,2);


        System.out.println("My coin is: "+coin\_human);


        System.out.println("Computer coin is: "+coin\_computer);



        if (coin\_human ==1 &&  coin\_computer==1) {

human_penny++;

computer_penny--;

        }

        else if(coin\_human ==2 &&  coin\_computer==2){

human_penny--;

computer_penny++;

        }


        System.out.println("Human Penny is: "+human\_penny);

        System.out.println("Computer Penny is: "+computer\_penny);


        if(human\_penny == 0 || computer\_penny == 0) {

break;

        }



    }



    if(human\_penny <= 0) {

        System.out.println("You have Won");

    }

    if(computer\_penny <=0) {

        System.out.println("You have lost");

    }

}

}

/r/AskProgramming Thread Parent