Arts >> Magic >> Magic Shows

What is the code for wizards return Alex vs Alex?

The code for Wizards Return: Alex vs. Alex is:

```

// Import the necessary libraries

import java.util.Scanner;

public class WizardsReturnAlexVsAlex {

public static void main(String[] args) {

// Create a scanner object to read user input

Scanner scanner = new Scanner(System.in);

// Prompt the user to enter the name of the first wizard

System.out.println("Enter the name of the first wizard:");

// Read the user's input and store it in the variable firstWizard

String firstWizard = scanner.nextLine();

// Prompt the user to enter the name of the second wizard

System.out.println("Enter the name of the second wizard:");

// Read the user's input and store it in the variable secondWizard

String secondWizard = scanner.nextLine();

// Create a variable to store the winner of the battle

String winner;

// If the first wizard's name is "Alex", they automatically win

if (firstWizard.equals("Alex")) {

winner = firstWizard;

}

// If the second wizard's name is "Alex", they automatically win

else if (secondWizard.equals("Alex")) {

winner = secondWizard;

}

// Otherwise, the battle is a tie

else {

winner = "Tie";

}

// Print the winner of the battle to the console

System.out.println("The winner is: " + winner);

}

}

```

Magic Shows

Related Categories