Method #1
class subtraction{
public static void main(String[] args){
int a=10;
int b=10;
int c=a-b;
System.out.println(c);
}}
OUTPUT: 20
Method #2
Import java.util.*;
class subtraction{
public static void main(String[] args){
Scanner scan= new Scanner (Syetem.in);
System.out.println("Enter 1st number:");
int a=scan.nextInt() ;
System.out.println("Enter 1st number:");
int b=scan.nextInt();
int c=a-b;
System.out.println(c);
}}
Method #3
Import java.util.*;
class subtraction{
public static void main(String[] args){
int a=10;
int b=10;
System.out.println(a-b);
}}
Method #4 (Using methods)
class Subtraction
public static void main(String[] args) {
int m=12;
int n=10;
int p= Sub(m,n);
System.out.println(p);
}
private static int Sub(int a, int b) {
int Sub=a-b;
return Sub;
}
}
class subtraction{
public static void main(String[] args){
int a=10;
int b=10;
int c=a-b;
System.out.println(c);
}}
OUTPUT: 20
Method #2
Import java.util.*;
class subtraction{
public static void main(String[] args){
Scanner scan= new Scanner (Syetem.in);
System.out.println("Enter 1st number:");
int a=scan.nextInt() ;
System.out.println("Enter 1st number:");
int b=scan.nextInt();
int c=a-b;
System.out.println(c);
}}
Method #3
class subtraction{
public static void main(String[] args){
int a=10;
int b=10;
System.out.println(a-b);
}}
Method #4 (Using methods)
class Subtraction
public static void main(String[] args) {
int m=12;
int n=10;
int p= Sub(m,n);
System.out.println(p);
}
private static int Sub(int a, int b) {
int Sub=a-b;
return Sub;
}
}
No comments:
Post a Comment