Question: CalculationGiven the class Calculationwith variables a and b , create a method getResult ( ) that will calculate and return the sum of the variables

CalculationGiven the class Calculationwith variables a and b, create a method getResult() that will calculate and return the sum of the variables a and b.
import java.io.*;
import java.util.*;
public class CodingQuestions {
public static class Calculation {
private int a;
private int b;
public Calculation(int a, int b){
this.a = a;
this.b = b;
}
/***** DO NOT CHANGE THE CODE ABOVE THIS LINE *****/
// Write your getResult() method here
}// end of Calculation class
/***** DO NOT CHANGE THE CODE BELOW THIS LINE *****/
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int x = in.nextInt();
int y = in.nextInt();
Calculation z = new Calculation(x, y);
int result = z.getResult();
System.out.println(result);
}// end of main()
}

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 Programming Questions!