Thursday, February 29, 2024

Java program to print table of n number from given range m to n.

import java.util.Scanner;
public class TableFromMtoN{
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("Enter the range of numbers from m to n for the multiplication table: ");
        int m = scanner.nextInt();
        int n = scanner.nextInt();
if(m<=n){
int x=m;
while(x<=n){
        System.out.println("Multiplication table for " + x + ":");

        for (int i = 1; i <= 10; i++) {
            int result = x * i;
            System.out.println(x + " * " + i + " = " + result);
        }
        x++;
       }
}
else{
System.out.println(" Numbers Range is Wrong,try Again");
}
}
}

No comments:

Post a Comment

Java program to implement file input stream class to read binary data from image file.

import java.io.FileInputStream; import java.io.IOException; public class ReadImageFile {     public static void main(String[] args) {       ...