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
In an application write a method filterStack that takes a stack of integers as a parameter...
In an application write a method filterStack that takes a stack of integers as a parameter and filters its elements (in a new Stack) in a way that places the even elements at the bottom and the odd ones at the top. The original stack should remain unchanged. You should use a queue (only one queue) as a temporary storage. Use stack and queue operations only to solve this problem. No need to write the main method. For example, if...
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.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT