Loops

Hello, so I recently started taking a java course at my Uni, but I can't quite seem to understand how loops are working. The goal i'm trying to achieve with my program is to hit the specied target by rolling a dice using Math.random. The part i'm struggling with is making the generator "roll" the dice automaticly until i hit my target, and not have me insert a new target after every failed attempt. If anyone is able to help me understand, it would be much appreciated!

I suggest you print your code in large writing on paper and go through the flow with a pencil. Look what happens if you get to line 7 because the user entered 7. Avoid System.exit; it won't do anything wrong there, but it can be dangerous in some other applications. Anyway, what will the user expect? They won't expect the program to stop before entering a new value. So you want something different for line 8. And when that part of the code is finished, do you really want else after it?
I don't like arithmetic with Math#random. I think it is error‑prone; you have got a formula which will work, but I prefer to use something different, as discussed here.
How have you been told to indent your code? Your indentation is very inconsistent; you shou‍ld decide on an indentation convention and stick to it rigidly. That way you will better be able to find errors. Look at lines 4 6 10 and 15. Line 10 is particularly risky because it is possible to look at it quickly and not realise where the else starts and ends. We have some formatting suggestions here.