title-img


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 →

Java Date and Time

The Calendar class is an abstract class that provides methods for converting between a specific instant in time and a set of calendar fields such as YEAR, MONTH, DAY_OF_MONTH, HOUR, and so on, and for manipulating the calendar fields, such as getting the date of the next week. You are given a date. You just need to write the method, getday , which returns the day on that date. To simplify your task, we have provided a portion of the code in the editor. For example, if you are given the dat

View Solution →

Java Currency Formatter

Given a double-precision number, payment, denoting an amount of money, use the NumberFormat class' getCurrencyInstance method to convert payment into the US, Indian, Chinese, and French currency formats. Then print the formatted values as follows: US: formattedPayment India: formattedPayment China: formattedPayment France: formattedPayment where formattedPayment is payment formatted according to the appropriate Locale's currency. Note: India does not have a built-in Locale, so you

View Solution →

"Hello World!" in C

Objective: In this challenge, we will learn some basic concepts of C that will get you started with the language. You will need to use the same syntax to read input and write output in many C challenges. As you work through these problems, review the code stubs to learn about reading from stdin and writing to stdout. Task: This challenge requires you to print Hello World! on a single line, and then print the already provided input string to stdout. If you are not familiar

View Solution →