You are on page 1of 1

Tutorial #2

How take input from user, perform a mathematical process and display the result. Then compare the
result against another number to see if it is greater than or less than that number.

import java.util.Scanner;

class AddNumbers

public static void main(String args[])

int x, y, z;

System.out.println("Enter two integers to calculate their sum");

Scanner ee = new Scanner(System.in);

x = ee.nextInt();

y = ee.nextInt();

z = x + y;

System.out.println("Sum of the integers = " + z);

if (z <= 10) {

System.out.println(z +" is less than or equal to 10”);

else{

System.out.println(z +" is greater than 10”);

You might also like