You are on page 1of 2

import java.io.

*;
public class Math {
public static void main(String[] args) throws IOException{
BufferedReader dataIn = new BufferedReader(new InputStreamReader
(System.in));
String a;
double n1, n2;
System.out.print("Enter First Number: ");
n1 = Double.parseDouble(dataIn.readLine());
System.out.print("Enter Second Number: ");
n2 = Double.parseDouble(dataIn.readLine());
System.out.println("Sum of " + n1 + " and " + n2 + " is " + (n1 + n2) +
".");
System.out.println("Difference of " + n1 + " and " + n2 + " is " + (n1 n2) + ".");
System.out.println("Product of " + n1 + " and " + n2 + " is " + (n1 * n2
) + ".");
System.out.println("Quotient of " + n1 + " and " + n2 + " is " + (n1 / n
2) + ".");
}
}

or

import java.io.*;
public class MOperation {
public static void main(String[] args) throws IOException{
BufferedReader dataIn = new BufferedReader(new InputStreamReader
(System.in));
String a;
double n1, n2;
System.out.print("Enter First Number: ");
a = dataIn.readLine();
n1 = Double.parseDouble(a);
System.out.print("Enter Second Number: ");
n2 = Double.parseDouble(dataIn.readLine());
System.out.println("Sum of " + n1 + " and " + n2 + " is " + (n1 + n2) +
".");
System.out.println("Difference of " + n1 + " and " + n2 + " is " + (n1 n2) + ".");

System.out.println("Product of " + n1 + " and " + n2 + " is " + (n1 * n2


) + ".");
System.out.println("Quotient of " + n1 + " and " + n2 + " is " + (n1 / n
2) + ".");
}
}

You might also like