English, asked by tjalbhadra4070, 1 month ago

Write a Java program to print the sum of two numbers. Test Data:74 + 36 Expected Output :110

Answers

Answered by pawarkarthik237
3

Explanation:

private int a;

private int b;

private int sum;

private int diff;

public void inputdata() {

Scanner in = new Scanner(System.in);

System.out.print("Enter first number: ");

a = in.nextInt();

System.out.print("Enter second number: ");

b = in.nextInt();

}

public void calculate() {

sum = a + b;

diff = a - b;

}

public void outputdata() {

System.out.println("Sum = " + sum);

System.out.println("Difference = " + diff);

}

public static void main(String args[]) {

Calculate obj = new Calculate();

obj.inputdata();

obj.calculate();

obj.outputdata();

}

}

Similar questions