HackerRank Java- Loops I




Given an integer, N, print its first 10 multiples. Each multiple N x i (where 1<= i <=10) should be printed on a new line in the form: N x i = result.



  1. import java.io.*;
  2. import java.math.*;
  3. import java.security.*;
  4. import java.text.*;
  5. import java.util.*;
  6. import java.util.concurrent.*;
  7. import java.util.regex.*;
  8. import java.util.Scanner;
  9. public class Solution {
  10. public static void main(String[] args) {
  11. Scanner scan = new Scanner(System.in);
  12. int multiplier = scan.nextInt();
  13. scan.close();
  14. for (int i = 1; i <= 10; i++) {
  15. System.out.format("%d x %d = %d%n", multiplier, i , i * multiplier);
  16. }
  17. }
  18. }




codesadda.com

Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube