Practical 3: Write a program to enter two numbers and perform mathematical operations on them.
Program:
import java.util.Scanner;
public class practical3
{
public static void main(String args[])
{
int a, b, res;
Scanner scan = new Scanner(System.in);
System.out.print("Enter Two Numbers : ");
a = scan.nextInt();
b = scan.nextInt();
res = a + b;
System.out.println("Addition = " +res);
res = a - b;
System.out.println("Subtraction = " +res);
res = a * b;
System.out.println("Multiplication = " +res);
res = a / b;
System.out.println("Division = " +res);
}
}
Output:
Comments
Post a Comment