Saturday, 20 August 2016

Java Program

Operator Example by Taking Input From User


import java.io.DataInputStream;
    class Operator{
        public static void main(String[]args) throws Exception{
            DataInputStream ob = new DataInputStream(System.in);
                System.out.print("Enter First Number ");
                    String a = ob.readLine();
                    int r = Integer.parseInt(a);
                System.out.print("Enter Second Number ");
                    String b = ob.readLine();
                    int s = Integer.parseInt(b);
                    int sum = r + s;
                    int min = r - s;
                    int mul = r * s;
                    int div = r / s;
                    int rem = r % s;
                System.out.print(" Sum is " + sum + " \n subtract is " + min + 
                                 " \n multiplication is " + mul + " \n division is " + div + 
                                 " \n reminder is " + rem);
        }
    }
                

No comments:

Post a Comment