Question

In: Computer Science

Write a method that takes four strings as parameter. The first string should be a pokemon...

Write a method that takes four strings as parameter. The first string should be a pokemon name, the second a pokemon type, the third a pokemon name, and the fourth a pokemon type. The method should print out which pokemon has the advantage over the other based on their type. In this case you can use fire, water, and leaf. Example outputs should be like:

Example:

Pokemon X (Water) has the advantage over Pokemon Y (fire)

Pokemon X (Fire) has the advantage over Pokemon Y (leaf)

Pokemon X (Leaf) has the advantage over Pokemon Y (water)

Solutions

Expert Solution

#include<bits/stdc++.h>
using namespace std;

void pokemon(string p1, string t1, string p2, string t2) {
  if (t1 == "water" && t2 == "fire") {
    cout << "Pokemon " << p1 << " (" << t1 << ")" << " has the advantage over Pokemon " << p2 << " (" << t2 << ")\n";
  } else if (t2 == "water" && t2 == "fire") {
    cout << "Pokemon " << p2 << " (" << t2 << ")" << " has the advantage over Pokemon " << p1 << " (" << t1 << ")\n";
  }else if (t1 == "fire" && t2 == "leaf") {
    cout << "Pokemon " << p1 << " (" << t1 << ")" << " has the advantage over Pokemon " << p2 << " (" << t2 << ")\n";
  } else if (t2 == "fire" && t2 == "leaf") {
    cout << "Pokemon " << p2 << " (" << t2 << ")" << " has the advantage over Pokemon " << p1 << " (" << t1 << ")\n";
  }else if (t1 == "leaf" && t2 == "water") {
    cout << "Pokemon " << p1 << " (" << t1 << ")" << " has the advantage over Pokemon " << p2 << " (" << t2 << ")\n";
  } else if (t2 == "leaf" && t2 == "water") {
    cout << "Pokemon " << p2 << " (" << t2 << ")" << " has the advantage over Pokemon " << p1 << " (" << t1 << ")\n";
  }
}

int main()
{
  pokemon("X","fire","Y","leaf");
}

OUTPUT:


Related Solutions

Please use JAVA to do this: Write a method that takes four strings as parameter. The...
Please use JAVA to do this: Write a method that takes four strings as parameter. The first string should be a pokemon name, the second a pokemon type(either fire, water, or leaf, where water beats fire, fire beats leaf and leaf beats water), the third a pokemon name, and the fourth a pokemon type. The method should print out which pokemon has the advantage over the other based on their type. Example: Pokemon X(which is the fire type) has the...
Java 1.Write a method removeEvenLength that takes an ArrayList of Strings as a parameter and that...
Java 1.Write a method removeEvenLength that takes an ArrayList of Strings as a parameter and that removes all of the strings of even length from the list. 2. Given the following Vehicle interface and client program in the Car class: public interface Vehicle{ public void move(); } public class Car implements Vehicle{ public static void main(String args[]) Vehicle v = new Vehicle(); // vehicle declaration } The above declaration is valid? True or False? 3. Java permits a class to...
Write a static method called "evaluate" that takes a string as a parameter
In Java language  Write a static method called "evaluate" that takes a string as a parameter. The string will contain a postfix expression, consisting only of integer operands and the arithmetic operators +, -, *, and / (representing addition, subtraction, multiplication, and division respectively). All operations should be performed as integer operations. You may assume that the input string contains a properly-formed postfix expression. The method should return the integer that the expression evaluates to. The method MUST use a stack...
Write a function that takes a C string as an input parameter and reverses the string.
in c++ Write a function that takes a C string as an input parameter and reverses the string. The function should use two pointers, front and rear. The front pointer should initially reference the first character in the string, and the rear pointer should initially reference the last character in the string. Reverse the string by swapping the characters referenced by front and rear, then increment front to point to the next character and decrement rear to point to the...
Write a subroutine that takes an int (.long) parameter and squares it. The parameter should be...
Write a subroutine that takes an int (.long) parameter and squares it. The parameter should be passed in on the stack. The answer should be returned in eax. The subroutine should not disturb any registers except eax, ecx, and edx. (Save any registers on the stack and restore them before exiting the subroutine.) Upon entry to the subroutine, push ebp, etc., to access the parameter.
Write a RECURSIVE method that receives a string as a parameter. The method will return true...
Write a RECURSIVE method that receives a string as a parameter. The method will return true if the string received as a parameter is a palindrome and false if it is not. The method must not have any loops! In JAVA
in c++ Write a function that takes a C string as an input parameter and reverses...
in c++ Write a function that takes a C string as an input parameter and reverses the string. The function should use two pointers, front and rear. The front pointer should initially reference the first character in the string, and the rear pointer should initially reference the last character in the string. Reverse the string by swapping the characters referenced by front and rear, then increment front to point to the next character and decrement rear to point to the...
Write a function named "characters" that takes a string as a parameter and returns the number...
Write a function named "characters" that takes a string as a parameter and returns the number of characters in the input string
Write a function called fnReadInParameters() that takes as parameter(s): • a string indicating the name of...
Write a function called fnReadInParameters() that takes as parameter(s): • a string indicating the name of the parameter le This function should return a dictionary that stores all of the parameter le data of the SIR model in a format that we will describe further below.
python Write a function pack_to_5(words) that takes a list of string objects as a parameter and...
python Write a function pack_to_5(words) that takes a list of string objects as a parameter and returns a new list containing each string in the title-case version. Any strings that have less than 5 characters needs to be expanded with the appropriate number of space characters to make them exactly 5 characters long. For example, consider the following list: words = ['Right', 'SAID', 'jO'] The new list would be: ['Right', 'Said ', 'Jo '] Since the second element only contains...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT