Multiply 2 Numbers In JAVA
Java Multiply 2 Numbers:
------------------------------------------------------------
import java.util.Scanner;
public class MyClass {
public static void main(String args[]) {
Scanner MyObj = new Scanner(System.in);
System.out.println("Enter 'X': ");
int x = MyObj.nextInt();
System.out.println("Enter 'Y': ");
int y = MyObj.nextInt();
if(x==0 || y==0){
System.out.println("!Cannot Multiply With '0'");
}
else{
int ans;
ans=x*y;
System.out.println("RESULT: " +ans);
}
}
}
-----------------------------------------------------------
------------------------------------------------------------
import java.util.Scanner;
public class MyClass {
public static void main(String args[]) {
Scanner MyObj = new Scanner(System.in);
System.out.println("Enter 'X': ");
int x = MyObj.nextInt();
System.out.println("Enter 'Y': ");
int y = MyObj.nextInt();
if(x==0 || y==0){
System.out.println("!Cannot Multiply With '0'");
}
else{
int ans;
ans=x*y;
System.out.println("RESULT: " +ans);
}
}
}
-----------------------------------------------------------
u can also do it on your user friendly calculator.......y same things again and again
ReplyDeleteThe Language Is Different This One Is Java Not C Language.......
Delete