"Rock Paper Scissors Game" Java What can make this code better?
And how could I improve this code?
Oh and what I would love is if someone has a project that is not that
challenging but I could learn a lot from it :)


&nbsp;

import java.util.Scanner;

public class RockPaperScissors {
    final static int ROCK = 1;
    final static int PAPER = 2;
    final static int SCISSORS = 3;

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("Start By Entering A number");
        int human = input.nextInt();
        System.out.println("ROCK IS 1 :: PAPER IS 2 :: SCISSORS 3");
        int computerScore = 0, humanScore = 0, computer;
        while (human != -1) {
            human = input.nextInt();
            computer = (int) (Math.random() * 3 + 1);
            String h = human == 1 ? "ROCK" : human == 2 ? "PAPER" : "SCISSORS";
            String c = computer == 1 ? "ROCK" : computer == 2 ? "PAPER" : "SCISSORS";
            if ((human == ROCK &amp;&amp; computer == SCISSORS) || (human == PAPER &amp;&amp; computer == ROCK) || (human == SCISSORS &amp;&amp; computer == PAPER)) {
                humanScore++;
                System.out.println("Human Won : " + humanScore);
                System.out.println("Human Chose " + h + " and Computer Chose " + c);
            } else if ((computer == ROCK &amp;&amp; human == SCISSORS) || (computer == PAPER &amp;&amp; human == ROCK) || (computer == SCISSORS &amp;&amp; human == PAPER)) {
                computerScore++;
                System.out.println("Computer Won : " + computerScore);
                System.out.println("Human Chose " + h + " and Computer Chose " + c);
            } else if (human == computer) {
                System.out.println("HAH YOU BOTH THINK THE SAME! ");
                System.out.println("DRAW!");
            } else {
                System.out.println("Something Went Wrong Try Again:( ");
            }
        }
        System.out.println("\n\nThe Scores Are *DRUM NOISES* ");
        for (int i = 0; i &lt; 4; i++) {
            System.out.println("------------------------------");
        }
        System.out.println("Human score : " + humanScore);
        System.out.println("Computer score : " + computerScore);
        if (humanScore &gt; computerScore) {
            System.out.println("Human Race Is saved! We Won!");
        } else if (computerScore &gt; humanScore) {
            System.out.println("Sadly We Lost. Better Luck Next Time:)");
        } else {
            System.out.println("Scores are Tied");
        }
    }
}
This is a reasonable first attempt but there are many ways to make it better:

public class RockPaperScissors {
    final static int ROCK = 1;
    final static int PAPER = 2;
    final static int SCISSORS = 3;



Consider using an enumerated type to hold related constants.

System.out.println("Start By Entering A number");

Your capitalization is not standard English.
Tell the user how to quit.

int human = input.nextInt();
System.out.println("ROCK IS 1 :: PAPER IS 2 :: SCISSORS 3");

Put the explanation before fetching input!
Why is there no "is" for the scissors case?

int computerScore = 0, humanScore = 0, computer;
while (human != -1) {

Consider refactoring the main method so that it more clearly reflects what is happening, and extracting state to an object.  I'd prefer to see your main look like this:




public static void main(String[] args) {
    initialize();
    Game g = new Game();
    g.printStartingText();
    while(!g.finished())
      g.playRound();
    g.printEndText();
}




Can you structure your program like that? It will be more clear if you do.

        String h = human == 1 ? "ROCK" : human == 2 ? "PAPER" : "SCISSORS";
        String c = computer == 1 ? "ROCK" : computer == 2 ? "PAPER" : "SCISSORS";



You've replicated some code here; it would be better to make a map from integer to the enumerated value and do two lookups in the map here.

    if ((human == ROCK &amp;&amp; computer == SCISSORS) || (human == PAPER &amp;&amp; computer == ROCK) || (human == SCISSORS &amp;&amp; computer == PAPER)) {

Instead of doing this work twice, write a method that returns PLAYER_1, PLAYER_2 or TIE:

    Winner w = getWinner(human, computer);



That will let you simplify the logic that follows, and it will be easier to read.

            System.out.println("Something Went Wrong Try Again:( ");



This should never happen. A better choice would be to assert that the condition is impossible.

    System.out.println("Human Race Is saved! We Won!");



Why are the humans "we"? The message is being produced by a computer! It should be "The human race is saved; you won and we computers lost." :)