Addition of two numbers:
Using the java program we can add two number . The java program is given below .PROGRAM
package helloworld;
import java.util.Scanner;
public class Addition {
public static void main(String[] args) {
Scanner addition=new Scanner(System.in);
int a,b,c;
System.out.println("Enter the first number ");
a=addition.nextInt();
System.out.println("Enter the second number ");
b=addition.nextInt();
c=a+b;
System.out.println("Addition of two numbers "+c);
}
}
OUTPUT
Subtraction of two numbers:
Using the java program we can subtract the two numbers. The code is given below!!
PROGRAM
package helloworld;
import java.util.Scanner;
public class Subtractions {
public static void main(String[] args) {
Scanner subtraction=new Scanner(System.in);
int a,b,c;
System.out.println("Enter the first number ");
a=subtraction.nextInt();
System.out.println("Enter the second number ");
b=subtraction.nextInt();
c=a-b;
System.out.println("subtraction of two numbers "+c);
}
}
OUTPUT
Multiplication of two numbers:
Using the java program you can multiple two numbers. The code is given below
PROGRAM
package helloworld;
import java.util.Scanner;
public class Multiplication {
public static void main(String[] args) {
Scanner multiplication=new Scanner(System.in);
int a,b,c;
System.out.println("Enter the first number ");
a=multiplication.nextInt();
System.out.println("Enter the second number ");
b=multiplication.nextInt();
c=a*b;
System.out.println("multiplication of two numbers "+c);
}
}
OUTPUT
multiplicationoutput |
Division of two numbers:
Using the java program you can divide the two numbers. The code is given below
Program:
package helloworld;
import java.util.Scanner;
public class Division {
public static void main(String[] args) {
Scanner Division=new Scanner(System.in);
int a,b,c;
System.out.println("Enter the first number ");
a=Division.nextInt();
System.out.println("Enter the second number ");
b=Division.nextInt();
c=a/b;
System.out.println("multiplication of two numbers "+c);
}
}
Super sir
ReplyDeletePost a Comment