Program for Substraction of two input number using 'Java'.

import java.util.Scanner; // Import the Scanner class

class subtraction {

  public static void main(String[] args) {

    int x, y, sub;

    Scanner sc = new Scanner(System.in); // Create a Scanner object

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

    x = sc.nextInt(); // Read user input


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

    y = sc.nextInt(); // Read user input


    sub = x + y;  // Calculate the substraction of x - y

    System.out.println("Subtraction of entered number is: " + sub); // Print the result

  }

Popular posts from this blog

In this problem, you will practice your knowledge on interfaces - Hacker Rank Solution.