We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Java
- Introduction
- Java Loops I
- Discussions
Java Loops I
Java Loops I
[deleted] + 59 comments As a C programmer
public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int N = in.nextInt(); for(int i = 1; i <= 10; i++){ System.out.printf("%d x %d = %d%n", N, i, N*i); } } }
+ 5 comments This is what I got but after reading the discussions, I a lot of people using the printf method. But this code here will do the same job. This code is in Java 8.
import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ Scanner sc = new Scanner(System.in); int input = sc.nextInt(); sc.close(); for(int i = 1; i <= 10; i++){ int answer = input*i; System.out.println(input + " x " + i + " = " + answer); } } }
+ 0 comments for(int i=0; i<10; i++){
System.out.printf("%d x %d = %d\n", N, (i+1), (N*(i+1)));
}
+ 0 comments IntStream.rangeClosed(1,10).forEachOrdered(i -> System.out.println(String.format("%d x %d = %d", N, i, i*N)));
+ 0 comments Here you'll get all the solutions of Java with explaination https://www.chase2learn.com/hackerrank-java-programming-solutions
Java - Introduction
- Welcome to Java!
- Java Stdin and Stdout I
- Java If Else
- Java Stdin and Stdout II
- Java Output Formatting
- Java loops I
- Java loops II
- Java Static Initializer Block
- Java Date and Time
- Java Currency Formatting
Java - Strings
- Java String Introduction
- Java Substring
- Java Substring Comparison
- Java String Reverse
- Java Anagrams
- Java String Tokens
- Java Regex
- Java Regex 2
- Valid username Regular Expression
Java - Object Oriented Programming
- Java Interface
- Java Method Overriding
- Java Method Overriding2
- Java Instanceof keyword
- Java Iterator
Java Exception Handling
- Java Exception Handling (Try-catch)
- Java Exception Handling
Java Advanced
- Java Varargs Simple Addition
- Java Reflection Attribute
- Can you Access?
- Prime Checker
- Java Factory Pattern
- Java Singleton Pattern
- Java Visitor Patterns
- Java Annotations
- Covariant Return Types
- Java Lambda Expression
- Java MD5
- Java SHA-256
Load more conversations
Sort 991 Discussions, By:
Please Login in order to post a comment