MainClass.java Source code

Java tutorial

Introduction

Here is the source code for MainClass.java

Source

import java.util.Scanner;

public class MainClass {
    public static void main(String args[]) {
        Scanner input = new Scanner(System.in);

        int number1;
        int number2;

        System.out.print("Enter first integer: "); // prompt 
        number1 = input.nextInt(); // read first number from user 

        System.out.print("Enter second integer: "); // prompt 
        number2 = input.nextInt(); // read second number from user 

        if (number1 == number2)
            System.out.printf("%d == %d\n", number1, number2);

        if (number1 != number2)
            System.out.printf("%d != %d\n", number1, number2);

        if (number1 < number2)
            System.out.printf("%d < %d\n", number1, number2);

        if (number1 > number2)
            System.out.printf("%d > %d\n", number1, number2);

        if (number1 <= number2)
            System.out.printf("%d <= %d\n", number1, number2);

        if (number1 >= number2)
            System.out.printf("%d >= %d\n", number1, number2);

    }

}