Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7565145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:04:35+00:00 2026-05-30T14:04:35+00:00

I am able to loop the program, but each time I input a value

  • 0

I am able to loop the program, but each time I input a value it will return 2 values, the user winning and the user losing. I’ve experimented using multiple methods and creating a new class which was the tester, but had some problems figuring out the logic. As for loops, I have tried using a for loop, while, and do while.

Thanks in advance!


// Rock Paper Scissor Shoot Game

import java.util.Random;
import java.util.Scanner;

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

    int wins = 0;
    int losses = 0;

    int rnd;


    for(rnd=0;rnd<=10;rnd++)
    {

    Random GAME = new Random();
    int PC = 1+GAME.nextInt(3);

    Scanner input = new Scanner (System.in);
    int SCISSOR, ROCK, PAPER;
    SCISSOR = 1;
    ROCK = 2;
    PAPER = 3;

    System.out.println("");
    System.out.println("Choose Your Weapon! ");
    System.out.println("1 = Scissor| 2 = Rock| 3 = Paper");
    System.out.println("");
    int USER =  input.nextInt();

    while (USER > 3) {
      System.err.println("Incorrect value entered, fool");
      System.err.println("Choose a number 1-3");
      return;
      }
    System.out.println("___________________");

    if(USER == PC){
      if(USER == SCISSOR){
        System.out.println("You Both Played Scissor");
      }
      if(USER == ROCK){
        System.out.println("You Both Played Rock");
      }
      if(USER == PAPER){
        System.out.println("You Both Played Paper");
      }
      System.out.println("Draw");
      System.out.println("___________________");
      System.out.println("Wins: " + wins + "| Losses: " + losses);
    }
    //User wins
    if(USER == SCISSOR && PC == PAPER){
      System.out.println("You: Scissor");
      System.out.println("PC: Paper");
      System.out.println("Scissor Cuts Paper");
      System.out.println("You Win!");
      System.out.println("___________________");
      wins++;
      System.out.println("Wins: " + wins + "| Losses: " + losses);
    }
    //Pc wins
    else if(PC == ROCK){
      System.out.println("You: Scissor");
      System.out.println("PC: Rock");
      System.out.println("Rock Breaks Scissor!");
      System.out.println("PC Wins!");
      System.out.println("___________________");
      losses++;
      System.out.println("Wins: " + wins + "| Losses: " + losses);
    }
    //User wins
    if(USER == ROCK && PC == SCISSOR ){
      System.out.println("You: Rock");
      System.out.println("PC: Scissor");
      System.out.println("Rock Breaks Scissor");
      System.out.println("You Win! ");
      System.out.println("___________________");
      wins++;
      System.out.println("Wins: " + wins + "| Losses: " + losses);
    }
    //Pc wins
    else if (PC == PAPER){
      System.out.println("You: Rock");
      System.out.println("PC: Paper");
      System.out.println("Paper Covers Rock!");
      System.out.println("PC Wins!");
      System.out.println("___________________");
      losses++;
      System.out.println("Wins: " + wins + "| Losses: " + losses);
    }
    //User Wins
    if(USER == PAPER && PC == ROCK){
      System.out.println("You: Paper");
      System.out.println("PC: Rock");
      System.out.println("Paper Covers Rock");
      System.out.println("You Win!");
      System.out.println("___________________");
      wins++;
      System.out.println("Wins: " + wins + "| Losses: " + losses);
    }
    // Pc Wins
    else if (PC == SCISSOR){
      System.out.println("You: Paper");
      System.out.println("PC: Scissor");
      System.out.println("Scissor Cuts Paper!");
      System.out.println("PC Wins!");
      System.out.println("___________________");
      losses++;
      System.out.println("Wins: " + wins + "| Losses: " + losses);
    }


  }





}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T14:04:36+00:00Added an answer on May 30, 2026 at 2:04 pm

    Your issue is your else/if selection blocks. Each time, you allow it to continue, even if the selection went through. You also aren’t checking properly. In each if/else pair you use, you check

    if(user X && pc Y) ...
    else if (pc Z) ...
    

    This will be evaluate one of the two blocks if the user plays X and the PC Y, OR if the PC plays z. You should have it set up to be:

    if(user X)
       if(pc Y) ...
       else if (pc Z) ...
    

    Or

    if(user X && pc Y) ...
    else if(user X && pc Z) ...
    

    I suggest the former. It is marginally more efficient because it only checks user X once. This won’t make half of a noticeable difference.

    You should do it like this:

    if(user plays paper)
        if(pc plays rock)
            ...
        else if (pc plays scissors)
            ...
    else if(user plays rock)
        if(pc plays scissors)
            ...
        else if (pc plays paper)
            ...
    else if(user plays scissors)
        if(pc plays rock)
            ...
        else if (pc plays paper)
            ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to be able to loop over only a section at a time
I have writted a Java program that will be able to add customers to
I want to be able to invoke an SSIS package at will from a
How can one loop a command/program in a Unix shell without writing the loop
I am writing a Visual C# program that executes a continuous loop of operations
Background Info: I have a program running through a list of url; each URL
I've written two programs. Now each program uses threading to send and receive packets
I am looking for a way to code a program which will multiply an
I am currently trying to write a program which asks the user for a
For my program I am trying to create a function that will generate an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.