QUESTION IMAGE
Question
jump to level 1
define a method calculateval() that has one integer parameter and returns the parameter plus 7.
ex: if the input is 5, then the output is:
12
1 import java.util.scanner;
2
3 public class valuecalculator {
4
5 / your code goes here /
6
7 public static void main(string args) {
8 scanner scnr = new scanner(system.in);
9 int input;
10 int result;
11
12 input = scnr.nextint();
13
14 result = calculateval(input);
15
Step1: Define the method
public static int calculateVal(int num) {
Step2: Return the result
return num + 7;
}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
import java.util.Scanner;
public class ValueCalculator {
public static int calculateVal(int num) {
return num + 7;
}
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
int input;
int result;
input = scnr.nextInt();
result = calculateVal(input);
System.out.println(result);
}
}