gpt-3.5-turbo-0301· openai
Suzhen/CodeChat
Build an if else ladder in java for pokemon weakness
- User
Build an if else ladder in java for pokemon weakness
- Assistant
Here's an example of an if-else ladder in Java for determining the weaknesses of a Pokemon based on its type:
String type = "Electric"; // example Pokemon type if (type.equals("Fire")) { System.out.println("Water type moves are super effective against " + type + " types."); } else if (type.equals("Water")) { System.out.println("Grass type moves are super effective against " + type + " types."); } else if (type.equals("Grass")) { System.out.println("Fire type moves are super effective against " + type + " types."); } else if (type.equals("Electric")) { System.out.println("Ground type moves are super effective against " + type + " types."); } else { System.out.println(type + " type does not have a known weakness."); }This ladder checks the type of the Pokemon and then uses a series of if-else statements to print out the corresponding weakness. If the Pokemon type doesn't match any of the known types, it prints out a default message.