I need help fixing (Printing correct information) a simple app where a player attacks a boss with a random generator
<p>Beginner java. I made this simple app where a player attacks a boss and the player has to tries to defeat the boss. What I am having trouble with is having my small java app to print after the boss has been defeated. My bosses' health is 5 and I have a random dice generator that ranges 1 - 6. When the player rolls "5" or a "6" on the first attack, I want the program to end. Another thing is that my program prints out I have defeated the boss even though the player has not dealt 5 or 6 of damage. I think it might be because of the for loop but I'm not sure :o</p>

<p>Here is the code:</p>

<pre><code>import java.util.Scanner;
import java.util.Random;


public class Hey{
public static void main (String args[]){

    Scanner attack = new Scanner(System.in);
    Random dice = new Random();

    String hits;
    int hitss,total = 0;

    System.out.println("Time to attack the boss!");
    System.out.println("Press letter 'A' to attack!");
    hits = attack.next();
    hitss = 1+dice.nextInt(6);

    for(int i=0;i&lt;2;i++){

    if(hits.equals ("a")){

        System.out.println("You have hit a " + hitss);
        total += hitss;
    }
    if(total &gt;= 5){
        System.out.println("Well done, You have defeated the boss!");

    }
    else if(total &lt; 5){
        total = 5 - total;
         System.out.println("You need " + total + " more hits to defeat the boss!");

    }

    else
    {
         System.out.println("Sorry, you did not defeat the boss");
    }

    }
    }
}
</code></pre>

<p>You have hit a 2
You need 3 more hits to defeat the boss!
You have hit a 2
Well done, You have defeated the boss!</p>
