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, , 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 date , the method should return as the day on that date.
Input Format
A single line of input containing the space separated month, day and year, respectively, in format.
Constraints
Output Format
Output the correct day in capital letters.
Sample Input
08 05 2015
Sample Output
WEDNESDAY
Explanation
The day on AugustthwasWEDNESDAY.
TO SOLVE THIS QUESTION YOU NEED IMPORT JAVA "time" PACKAGE BY
"import java.time.*;
in this package you will use the method "LocalDate"
and the solution is
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.*;
import java.util.regex.*;
import java.util.stream.*;
importstatic java.util.stream.Collectors.joining;
importstatic java.util.stream.Collectors.toList;
import java.time.LocalDate;
class Result {
/*
* Complete the 'findDay' function below.
*
* The function is expected to return a STRING.
* The function accepts following parameters:
* 1. INTEGER month
* 2. INTEGER day
* 3. INTEGER year
*/
publicstatic String findDay(int month, int day, int year) {
QUESTION IS 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 are given a class Solution with a main method. Complete the given code so that it outputs the area of a parallelogram with breadth and height . You should read the variables from the standard input. If or , the output should be "java.lang.Exception: Breadth and height must be positive" without quotes. Input Format There are two lines of input. The first line contains : the breadth of the parallelogram. The next line contains : the height of the parallelogram. Constraints Output Format If both values are greater than zero, then the main method must output the area of the parallelogram . Otherwise, print "java.lang.Exception: Breadth and height m...
HERE IS THE QUESTION. The challenge here is to read lines of input until you reach EOF , then number and print all lines of content. Hint: Java's Scanner.hasNext() method is helpful for this problem. Input Format Read some unknown lines of input from stdin(System.in) until you reach EOF ; each line of input contains a non-empty String . Output Format For each line, print the line number, followed by a single space, and then the line content received as input. Sample Input Hello world I am a file Read me until end-of-file. Sample Output 1 Hello world 2 I am a file 3 Read me until end-of-file. SOLUTION IS: import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { int i= 1 ; Sca...
QUESTION IS You are given an integer , you have to convert it into a string. Please complete the partially completed code in the editor. If your code successfully converts into a string the code will print " Good job ". Otherwise it will print " Wrong answer ". can range between to inclusive. Sample Input 0 100 Sample Output 0 Good job WAYS TO CONVERT TO AN INTEGER TO STRING IS Here are 2 ways to convert an int to a String String s = String . valueOf ( n ); String s = Integer . toString ( n ); AND THE SOLUTION IS import java.util.*; import java.security.*; public class Solution { public static void main(String[] args) { DoNotTerminate.forbidExit(); try { Scanner in = new Scanner(System.in); int n = in .nextInt(); in.clos...
Comments
Post a Comment