Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

jump to level 1 define a method calculateval() that has one integer par…

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

Explanation:

Step1: Define the method

public static int calculateVal(int num) {

Step2: Return the result

    return num + 7;
}

Answer:

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);
    }
}