Question: Java Programming Write a method that takes 3 parameters: 2 double, (num1 and num2) and 1 char (type), in that order, and returns a double

Java Programming

Java Programming Write a method that takes 3 parameters: 2 double, (num1

Write a method that takes 3 parameters: 2 double, (num1 and num2) and 1 char (type), in that order, and returns a double value (rounded to two decimal places - use Math.round0) dependent on the following rules. char (type) can only be one of +-*, /, or %. If type is: + then add num1 and num2. -' if num1 is greater than num2 then subtract num2 from num1, otherwise subtract num1 from num2. then multiply num1 and num2. if num2 equals zero then return 0, otherwise divide num1 by num2. 'W then return the modulo division of num1 and num2. if it is any other character then return -1.0 doCalculation(3.5, 4.2, )The value of the calcuation is: 7.7 doCalculation(3.5, 4.2, -)- The value of the calcuation is: 0.7 doCalculation(3.5, 4.2, )- The value of the calcuation is: 14.7 doCalculation(3.5, 4.2, ')-The value of the calcuation is: 0.83 doCalculation(35, 42, 96') The value of the calcuation is: 3.5 doCalculation(3.5, 4.2, 'P)-The value of the calcuation is:-1.0 For example: Test Result The value of the calculation is: 1 double numi-974.32, num2 -921.69; char c '/'; System.out.println("The value of the calculation is: " +doCalculation (num1, num2, 06

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!