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 challenge. Output Format You must print two lines of output: Print Hello, World. on the first
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.out.println("myString is: " + myString); System.out.println("myInt is: " + myInt); The code abov
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 is even and in the inclusive range of 6 to 20 , print Weird If is even and greater than 20 , print
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 input: The first line contains an integer. The second line contains a double. The third line conta
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. Each String will have a maximum of 10 alphabetic characters, and each integer will be in the inclusi
View Solution →