Welcome to Java!

Welcome to the world of Java! In this challenge, we practice printing to stdout. The code stubs in your editor declare a Solution class and a main method. Complete the main method by copying the two lines of code below and pasting them inside the body of your main method. System.out.println("Hello, World."); System.out.println("Hello, Java."); Input Format There is no input for this cha

View Solution →

Java Stdin and Stdout I

Most HackerRank challenges require you to read input from stdin (standard input) and write output to stdout (standard output). One popular way to read input from stdin is by using the Scanner class and specifying the Input Stream as System.in. For example: Scanner scanner = new Scanner(System.in); String myString = scanner.next(); int myInt = scanner.nextInt(); scanner.close(); System.

View Solution →

Java If-Else

In this challenge, we test your knowledge of using if-else conditional statements to automate decision-making processes. An if-else statement has the following logical flow: Wikipedia if-else flow chart Source: Wikipedia Task Given an integer, n, perform the following conditional actions: If is odd, print Weird If is even and in the inclusive range of 2 to 5, print Not Weird If i

View Solution →

Java Stdin and Stdout II

In this challenge, you must read an integer, a double, and a String from stdin, then print the values according to the instructions in the Output Format section below. To make the problem a little easier, a portion of the code is provided for you in the editor. Note: We recommend completing Java Stdin and Stdout I before attempting this challenge. Input Format There are three lines of inp

View Solution →

Java Output Formatting

Java's System.out.printf function can be used to print formatted output. The purpose of this exercise is to test your understanding of formatting output using printf. To get you started, a portion of the solution is provided for you in the editor; you must format and print the input to complete the solution. Input Format Every line of input will contain a String followed by an integer. E

View Solution →