10. Translate the following pseudo code about how to structure your code). While guessX does not equal randomX OR guess Y does not equal randomY If guessX was too high Inform the player to guess lower next time Alternatively, if it was too low Inform the player to guess higher next time If guess Y was too high Inform the player to guess lower next time Alternatively, if it was too low Inform the player to guess higher next time If guessX was wrong Prompt the user for a new guess of the X value Save that to guessX If guess Y was wrong Prompt the user for a new guess of the Y value Save that to guess Y

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
I need help translating it
### Translating Pseudocode to Java: A Step-by-Step Guide

This tutorial will guide you through translating the following pseudocode into Java. Pay special attention to indentation, as it helps structure your code properly. 

#### Pseudocode

```
While guessX does not equal randomX OR guessY does not equal randomY
    If guessX was too high
        Inform the player to guess lower next time
    Alternatively, if it was too low
        Inform the player to guess higher next time
    If guessY was too high
        Inform the player to guess lower next time
    Alternatively, if it was too low
        Inform the player to guess higher next time
    If guessX was wrong
        Prompt the user for a new guess of the X value
        Save that to guessX
    If guessY was wrong
        Prompt the user for a new guess of the Y value
        Save that to guessY
```

### Java Translation

Here is how you can translate the above pseudocode into Java:

```java
import java.util.Scanner;

public class GuessingGame {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int randomX = (int)(Math.random() * 100); // Random number between 0 and 99
        int randomY = (int)(Math.random() * 100); // Random number between 0 and 99
        int guessX = -1;
        int guessY = -1;

        while (guessX != randomX || guessY != randomY) {
            if (guessX != -1) {
                if (guessX > randomX) {
                    System.out.println("Guess lower for X next time.");
                } else if (guessX < randomX) {
                    System.out.println("Guess higher for X next time.");
                }
            }

            if (guessY != -1) {
                if (guessY > randomY) {
                    System.out.println("Guess lower for Y next time.");
                } else if (guessY < randomY) {
                    System.out.println("Guess higher for Y next time.");
                }
            }

            System.out.print("Enter your guess for X: ");
            guessX = scanner.nextInt();
            System.out.print("Enter your guess for Y: ");
            guessY = scanner.nextInt();
        }
        
        System.out.println("Congratulations!
Transcribed Image Text:### Translating Pseudocode to Java: A Step-by-Step Guide This tutorial will guide you through translating the following pseudocode into Java. Pay special attention to indentation, as it helps structure your code properly. #### Pseudocode ``` While guessX does not equal randomX OR guessY does not equal randomY If guessX was too high Inform the player to guess lower next time Alternatively, if it was too low Inform the player to guess higher next time If guessY was too high Inform the player to guess lower next time Alternatively, if it was too low Inform the player to guess higher next time If guessX was wrong Prompt the user for a new guess of the X value Save that to guessX If guessY was wrong Prompt the user for a new guess of the Y value Save that to guessY ``` ### Java Translation Here is how you can translate the above pseudocode into Java: ```java import java.util.Scanner; public class GuessingGame { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int randomX = (int)(Math.random() * 100); // Random number between 0 and 99 int randomY = (int)(Math.random() * 100); // Random number between 0 and 99 int guessX = -1; int guessY = -1; while (guessX != randomX || guessY != randomY) { if (guessX != -1) { if (guessX > randomX) { System.out.println("Guess lower for X next time."); } else if (guessX < randomX) { System.out.println("Guess higher for X next time."); } } if (guessY != -1) { if (guessY > randomY) { System.out.println("Guess lower for Y next time."); } else if (guessY < randomY) { System.out.println("Guess higher for Y next time."); } } System.out.print("Enter your guess for X: "); guessX = scanner.nextInt(); System.out.print("Enter your guess for Y: "); guessY = scanner.nextInt(); } System.out.println("Congratulations!
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY