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 →Java Strings Introduction
This exercise is to test your understanding of Java Strings. A sample String declaration: String myString = "Hello World!" The elements of a String are called characters. The number of characters in a String is called the length, and it can be retrieved with the String.length() method. Given two strings of lowercase English letters, A and B, perform the following operations: 1.Sum the lengths of A and B. 2.Determine if is lexicographically A larger than B(i.e.: does B come before A
View Solution →Java Substring
Given a string, s, and two indices, start and end, print a substring consisting of all characters in the inclusive range from start to end-1. You'll find the String class' substring method helpful in completing this challenge. Input Format The first line contains a single string denoting s. The second line contains two space-separated integers denoting the respective values of start and end. Constraints 1<=|s|<=100 0<=start<end<=n String s consists of English alphabetic letters
View Solution →Java Substring Comparisons
We define the following terms: Lexicographical Order, also known as alphabetic or dictionary order, orders characters as follows: A<B<...<Y<Z<a<b<...<y<z For example, ball < cat, dog < dorm, Happy < happy, Zoo < ball. A substring of a string is a contiguous block of characters in the string. For example, the substrings of abc are a, b, c, ab, bc, and abc. Given a string, s, and an integer, k, complete the function so that it finds the lexicographically smallest and largest sub
View Solution →