QUESTION IMAGE
Question
jump to level 1
define a method calculateresult() that has two double parameters and returns the result of subtracting the product of 6.9 and the second parameter from the first parameter.
ex: if the input is 8.5 8.8, then the output is:
-52.22
1 import java.util.scanner;
2
3 public class numbercalculator {
4
5 / your code goes here /
6
7 public static void main(string args) {
8 scanner scnr = new scanner(system.in);
9 double valuein1;
10 double valuein2;
11 double result;
12
13 valuein1 = scnr.nextdouble();
14 valuein2 = scnr.nextdouble();
15
Step1: Define the method
The method calculateResult takes two double parameters. The syntax for defining a method in Java is public static double calculateResult(double param1, double param2).
Step2: Implement the calculation
The formula to calculate the result is param1 - (6.9 param2). So the body of the method is return param1 - (6.9 param2);.
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
public static double calculateResult(double param1, double param2) {
return param1 - (6.9 * param2);
}