Question: 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

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

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.round()) 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 '%', then return the modulo division of num1 and num2. doCalculation (3.5, 4.2, '+') rightarrow The value of the calculation is: 7.7 doCalculation (3.5, 4.2, '-') rightarrow The value of the calculation is: 0.7 doCalculation (3.5, 4.2, '*') rightarrow The value of the calculation is: 14.7 doCalculation (3.5, 4.2, '/') rightarrow The value of the calculation is: 0.83 doCalculation (3.5, 4.2, '%') rightarrow The value of the calculation is: 3.5

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!