We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1
IMPORTANT SNIPPETS OF JAVA
Printing Range of Numbers between m and n
import java.util.Scanner; class RangeConditionPrinter { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // Step 1: Input the range System.out.println("Enter the starting number (m):"); int m = sc.nextInt(); System.out.println("Enter the ending number (n):"); int n = sc.nextInt(); // Step 2: Loop through the range System.out.println("Numbers satisfying the condition between " + m + " and " + n + ":"); for (int i = m; i <= n; i++) { // Step 3: Check the condition if (/* condition to check */) { // Step 4: Print the number System.out.println(i); }}}}