Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Java Program to Subtract Any Two Numbers

Java programs

This is a very basic Program in Java programming language. If you are a Java beginners or want to start learning Java programming language, then this program will help you to understand the basic Java programming. In this post, I will explain about a Java program to subtract any two numbers with an example and program output.

Java Program to Substract Any Two Numbers

Before executing this program I assume you have configured Java in your computer.

Copy the below program and create a file “SubstractProgram.java” and execute it to subtract any two numbers.

import java.io.*;

class SubstractProgram
{
  public static void main(String args[])throws Exception
  {
    int a,b,c;
    BufferedReader br= new BufferedReader( new InputStreamReader(System.in));
    System.out.println("Enter any two numbers to subtract:");
    a=Integer.parseInt(br.readLine());
    b=Integer.parseInt(br.readLine());
    c = a-b;
    System.out.println("\nSubtract of two numbers:"+ c);
  }
}

Program Output

Enter any two numbers to subtract:
50
20
Subtract of two numbers: 30

The post Java Program to Subtract Any Two Numbers appeared first on FreeWebMentor.



This post first appeared on Programming Blog Focused On Web Technologies, please read the originial post: here

Share the post

Java Program to Subtract Any Two Numbers

×

Subscribe to Programming Blog Focused On Web Technologies

Get updates delivered right to your inbox!

Thank you for your subscription

×