Leatheling

Top 5 This Week

Related Posts

4.7.11 Rock Paper Scissors – Complete Beginner Guide & Working Code (2025)

Students everywhere search for 4.7.11 Rock Paper Scissors because it is the famous CodeHS assignment in Unit 4 that teaches if/else logic, random numbers, and loops all in one fun game. You play against the computer1: choose rock, paper, or scissors, the program picks randomly, and it tells who wins. This project feels like a real game while you practice important coding skills. Thousands of high school and early college students finish 4.7.11 Rock Paper Scissors every year to earn full points. In 2025 the task stays the same – clean, simple Java code that runs in the console. This guide gives you everything: rules, logic, full code, and tips to get 100%. For easier learning, try trend-your-guide

4.7.11 Rock Paper Scissors – Complete Beginner Guide & Working Code (2025)

What You Must Do in 4.7.11 Rock Paper Scissors

The 4.7.11 Rock Paper Scissors assignment asks you to write a program that plays the classic game until the user quits. You need a Scanner for player input, Math.random() for the computer choice, and if/else statements to decide the winner. The game should ignore capital letters, show clear messages, and ask to play again. CodeHS checks for correct logic, no extra libraries, and good variable names. Most students finish in 30–60 minutes once they understand the flow. The program ends only when the player types something like “no” or “quit”.

Step-by-Step Plan to Build 4.7.11 Rock Paper Scissors

Follow this easy plan for 4.7.11 Rock Paper Scissors. First import Scanner and start the main method. Print a welcome message and start a do-while loop. Inside the loop ask the player for rock, paper, or scissors. Generate a random number 0–2 for the computer. Convert the number to “rock”, “paper”, or “scissors”. Compare both choices with nested if/else and print win, lose, or tie. Ask if they want to play again. Loop until they say no. This plan keeps your code clean and easy to read.

Step-by-Step Plan to Build 4.7.11 Rock Paper Scissors

Full Working Code for 4.7.11 Rock Paper Scissors

Here is the complete, tested code for 4.7.11 Rock Paper Scissors that earns full points on CodeHS in 2025:

Java

import java.util.Scanner;

public class RockPaperScissors {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);

        String playAgain = “yes”;

        do {

            System.out.println(“Choose rock, paper, or scissors:”);

            String player = scan.nextLine().toLowerCase();

            int computerNum = (int)(Math.random() * 3);

            String computer = “”;

            if (computerNum == 0) computer = “rock”;

            else if (computerNum == 1) computer = “paper”;

            else computer = “scissors”;

            System.out.println(“Computer chose ” + computer);

            if (player.equals(computer)) {

                System.out.println(“It’s a tie!”);

            } else if ((player.equals(“rock”) && computer.equals(“scissors”)) ||

                       (player.equals(“paper”) && computer.equals(“rock”)) ||

                       (player.equals(“scissors”) && computer.equals(“paper”))) {

                System.out.println(“You win!”);

            } else {

                System.out.println(“Computer wins!”);

            }

            System.out.println(“Play again? (yes/no)”);

            playAgain = scan.nextLine().toLowerCase();

        } while (playAgain.equals(“yes”));

        System.out.println(“Thanks for playing!”);

        scan.close();

    }

}

Copy, paste, run – it works perfectly.

Common Mistakes in 4.7.11 Rock Paper Scissors & Fixes

Many students lose points on 4.7.11 Rock Paper Scissors because they forget toLowerCase() and the game fails with capital letters. Others use three separate random calls instead of one number. Some forget the do-while loop, so the game stops after one round. A few write only if statements without else, so ties don’t show. Another mistake is closing Scanner too early. Always test with “Rock”, “ROCK”, and “rock” to make sure it works. Fix these and you get full credit fast.

Extra Challenges After Finishing 4.7.11 Rock Paper Scissors

Once your 4.7.11 Rock Paper Scissors runs perfectly, make it better for fun. Add a score counter that tracks wins for player and computer. Play best-of-three rounds. Add “lizard” and “spock” for the big bang version. Show funny messages for each win. Use a switch statement instead of if/else. Make the computer remember your last move and try to beat it. These extras help you learn more than the basic assignment.

Extra Challenges After Finishing 4.7.11 Rock Paper Scissors

FAQs About 4.7.11 Rock Paper Scissors

What are 4.7.11 Rock Paper Scissors on CodeHS?

4.7.11 Rock Paper Scissors is a popular assignment in CodeHS Unit 4 where you code a full rock-paper-scissors game in Java. The program lets the player choose, the computer picks randomly, and it announces the winner. You must use loops so the game continues until the player quits. It teaches random numbers, conditionals, and user input. Most students finish it in one class period2.

Why does my 4.7.11 Rock Paper Scissors not accept capital letters?

You need .toLowerCase() on both player and computer choices in 4.7.11 Rock Paper Scissors. Without it the program treats “Rock” and “rock” as different strings. Add .toLowerCase() right after reading input and when setting computer choice. This small fix makes your game strong and earns full points.

How do I make the computer choice random in 4.7.11 Rock Paper Scissors?

Use (int)(Math.random() * 3) to get 0, 1, or 2 in 4.7.11 Rock Paper Scissors. Then use if/else or switch to turn 0 into “rock”, 1 into “paper”, and 2 into “scissors”. This is the cleanest way CodeHS expects. Never write three separate random calls – one is enough.

Do I need a while loop or do-while for 4.7.11 Rock Paper Scissors?

Use a do-while loop for 4.7.11 Rock Paper Scissors so the game plays at least once. Ask “Play again?” at the end and loop while the answer equals “yes”. A regular while loop would skip the first game. Do-while is perfect for this assignment.

Can I use switch instead of if/else in 4.7.11 Rock Paper Scissors?

Yes! Switch works great for 4.7.11 Rock Paper Scissors when you convert the random number to a string first. Many students use switches and still get full credit. Both ways are correct – pick the one you like best.

Conclusion

The 4.7.11 Rock Paper Scissors project is the perfect way to practice Java basics while building a fun game3. With clear logic, random choices, and a loop, you finish fast and learn skills that help in every future program. Copy the code above, understand each line, and you will ace this assignment in 2025.Did this help you finish 4.7.11 Rock Paper Scissors? Tell us your score below!

References

  1. CodeHS Official Resources – Original problem statement.
    ↩︎
  2. CodeHS Unit 4 Flashcards – Student answers and tips. ↩︎
  3. Course Hero – 4.7.11 Rock Paper Scissors PDF – Full assignment description. ↩︎
Noah
Noahhttp://leatheling.com
Noah is the voice behind Leatheling, where he explores the intersection of business, technology, and everyday living. With a focus on clear insights and practical ideas, he writes to help readers make smarter decisions—whether it’s in finance, career, or lifestyle. When he’s not writing, Noah’s usually testing new tech, planning his next trip, or finding simple ways to make life more efficient.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Popular Articles