Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class TwoNumbers {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- System.out.println("Enter first integer");
- int num1= scanner.nextInt();
- scanner.nextLine();
- System.out.println("Enter second integer");
- int num2 = scanner.nextInt();
- System.out.println("Your first number is: " + num1);
- System.out.println("Your second number is: " + num2);
- if ((num1 <= 0 && num2 > 0) || (num1 > 0 && num2 <= 0)) {
- System.out.println("The product of two numbers is: " + String.valueOf(num1 * num2));
- } else {
- if (num1 > num2)
- System.out.println("The difference of two numbers is: " + String.valueOf(num1 - num2));
- if (num1 < 0 && num2 < 0)
- System.out.println("The sum of two numbers is: " + String.valueOf(num1 + num2));
- else if(num2 != 0){
- System.out.println("The modulo of first to second number is: " + String.valueOf(num1 % num2));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement