In this tutorial learn how you can divide two numbers and print on the screen in java. We will define two variables and use another variable divide for storing the result. Then we print the result.

Java is a high-level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible.

Write a Program to Divide Two Numbers and Print on the Screen

Here is the code to divide two numbers and print them on the screen in Java programming.

//Write a Java program to divide two numbers and print on the screen.
import java.util.Scanner;

public class Divide {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("Enter First number:");
        int a = sc.nextInt();
        System.out.println("Enter Second number");
        int b = sc.nextInt();
        int divide = a / b;
        System.out.println("When " + a + " is divided by " + b + " the result becomes " + divide + ".");
        sc.close();

    }
}

Test Live At Jdoodle

Conclusion

This is how you can divide two numbers and print them on the screen in java programming. Comment below if you like our tutorial.