A method named isAnOperation that takes a character and returns true if the character is one of the operations +, -, *, /, %, and false otherwise. The header of the method is as follows: public static boolean isAnOperation(char operation) 2. A method named getResult that takes two floating point numbers and a character: the method returns a String that includes the two numbers, the operation, and the result. The header of the method is as follows: public static String getResult(double num1, double num2, char operation) For example, if the two floating point numbers are 12.5 and 11.4, and the operation + is passed to the method it must return the following String: 12.5 + 11.4 = 23.9
Please help me solve this with java
A method named isAnOperation that takes a character and returns true if the character
is one of the operations +, -, *, /, %, and false otherwise.
The header of the method is as follows:
public static boolean isAnOperation(char operation)
2. A method named getResult that takes two floating point numbers and a character: the
method returns a String that includes the two numbers, the operation, and the result.
The header of the method is as follows:
public static String getResult(double num1, double num2, char operation)
For example, if the two floating point numbers are 12.5 and 11.4, and the operation + is
passed to the method it must return the following String:
12.5 + 11.4 = 23.9
3. In your main method:
a. Read two floating point numbers from the user. You must prompt the user to enter
the numbers with appropriate messages.
b. Read the operation to be performed between the two numbers from the user. You
must prompt the user to enter the operation with an appropriate message. You must
invoke the isAnOperation method to check that the operation is valid. If it’s not valid,
your program must keep on prompting the user to enter an operation from (+,-,*,/%)
until a valid operation is entered.
c. Invoke the getResult method by passing the entered numbers and operation and print
the returned String to the console.
Step by step
Solved in 3 steps with 1 images