Rock Paper Scissors programme [closed]

I have been frustrated with this code. The goal is to create a rock paper scissors game, best of 3. I have tried to make a "while" loop but I’ve got it all wrong and ended up scrapping it back to what I started with, a non-looping code.

If anyone can enlighten me how to make it loop until the computer or player gets a score of 3 wins, I would be so grateful!! Thank you so much
Sorry I should clarify, it needs to loop until the user or computer has 3 wins, so they rebattle until the user or computer reaches 3 wins

import java.util.Scanner;
import java.util.Random;
    
public class RockPaperScissors
{

public static void main(String[] args)
{
    Scanner key;
    Random randGen;
    char userChoice, computerChoice;
    int winner, compInt;

    int computerScore;
    int userScore;
    int scoreCounter;

    /***** INITIALIZATION SECTION *****/
    key = new Scanner(System.in);
    randGen = new Random();
    userChoice = ' ';
    computerChoice = ' ';
    //winner = -1;
    compInt = -1;
    computerScore = 0;
    userScore = 0;
    scoreCounter = 0;

    System.out.println("What is your name?");
    String name = key.nextLine();
    System.out.println(name + " play rock, paper, or scissors with me!!");

    /***** INPUT SECTION *****/
    System.out.println("Please enter R for rock, P for paper, or S for scissors:");
    userChoice = key.next().toUpperCase().charAt(0);

    //key.close();

    /***** PROCESSING SECTION *****/
    compInt=randGen.nextInt(3);
    if (compInt == 0)
    {
        computerChoice = 'R';
    }
    else if (compInt == 1)
    {
        computerChoice = 'P';
    }
    else if (compInt == 2)
    {
        computerChoice = 'S';
    }
    
    winner = RockPaperScissors.decideWinner(userChoice,computerChoice);

    /***** OUTPUT SECTION *****/
    System.out.printf("Player: %c%nComputer: %c%n", userChoice, computerChoice);

   switch (winner)
    {
        case 0:
            System.out.println("It's a tie!");
            System.out.println(name + ": " + userScore + ", Computer:" + computerScore );
            break;

        case 1:
            System.out.println("You won!");
            userScore++;
            System.out.println(name + ": " + userScore + ", Computer:" + computerScore );
            break;

        case 2:
            System.out.println("Computer won!");
            computerScore++;
            System.out.println(name + ": " + userScore + ", Computer:" + computerScore );
            break;

        default:
            System.out.println("Invalid choice, try again.");
            break;
    }
    //System.out.println("Thanks for playing!);
}

/***** STATIC METHODS *****/
/**Description: given two characters (R,P, or S) determines winner using rock
 * paper rules. Assume input is valid and error checking is done in main
 * programme. **/

public static int decideWinner(char p1,char p2)
{
    String combo;
    combo = String.format("%c%c", p1, p2);

    switch(combo)
    {
        case "RS":
        case "PR":
        case "SP":
            return 1;

        case "RP":
        case "PS":
        case "SR":
            return 2;

        case "RR":
        case "PP":
        case "SS":
            return 0;

    }
    return -1;
}

}
/***************************************************
 while(userScore == 3)
        {
            System.out.println("You won the game" +name+ "! Congratulations");
            scoreCounter++;
        }
        while(computerScore == 3)
        {
            System.out.println("Sorry " +name+ ", Computer won...");
            scoreCounter++;
        }
 **************************************************/
%d bloggers like this: