title-img


Java Loops I

Objective In this challenge, we're going to use loops to help us do some simple math. Task 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. Input Format A single integer, N. Constraints 2 <= N <= 20 Output Format Print 10 lines of output; each line i (where 1 <= i <= 10 ) contains the result of N x i in the form: N x i = result. Sample Input 2 Sample Ou

View Solution →

Java Datatypes

Java has 8 primitive data types; char, boolean, byte, short, int, long, float, and double. For this exercise, we'll work with the primitives used to hold integer values (byte, short, int, and long): A byte is an 8-bit signed integer. A short is a 16-bit signed integer. An int is a 32-bit signed integer. A long is a 64-bit signed integer. Given an input integer, you must determine which primitive data types are capable of properly storing that input. To get you started, a portion of the

View Solution →

Java End-of-file

"In computing, End Of File (commonly abbreviated EOF) is a condition in a computer operating system where no more data can be read from a data source." — (Wikipedia: End-of-file) The challenge here is to read n lines of input until you reach EOF, then number and print all n lines of content. Hint: Java's Scanner.hasNext() method is helpful for this problem. Input Format Read some unknown n lines of input from stdin(System.in) until you reach EOF; each line of input contains a non-e

View Solution →

Java Static Initializer Block

Static initialization blocks are executed when the class is loaded, and you can initialize static variables in those blocks. It's time to test your knowledge of Static initialization blocks. You can read about it here. You are given a class Solution with a main method. Complete the given code so that it outputs the area of a parallelogram with breadth B and height H . You should read the variables from the standard input. If B <=0 or H <=0 , the output should be "java.lang.Exception: B

View Solution →

Java Int to String

You are given an integer n , you have to convert it into a string. Please complete the partially completed code in the editor. If your code successfully converts n into a string s the code will print "Good job". Otherwise it will print "Wrong answer". n can range between -100 to 100 inclusive. Sample Input 0 100 Sample Output 0 Good job

View Solution →