1 answer

3. Using no date-specific Java libraries, write a program that computes the number of days between...

Question:

3. Using no date-specific Java libraries, write a program that computes
the number of days between any two dates (inclusive). You must take
into account leap years. The rule for computing a leap year is as
follows: If the year is divisible by 4 it is a Leap Year ...
Unless the year is divisible by 100, then it is _not_ a Leap Year
... Unless the year is divisible by 400, then it _is_ a Leap Year.

During a Leap year, an extra day is added at the end of the month
of Feb.

ex. 1000 is not a Leap Year
2000 is a Leap year

Your program must be run as follows:
PROMPT>> java DaysBetween 11/11/2002 11/12/2002
1 day
(program ends)

Error checking. Be sure to handle at least the following:
- if there is too few or too many input parameters
- if the date strings are not in the proper format
(simply echo usage statement);
- if date 1 is not earlier than date 2


Answers

I HOPE ITS HELPFULL TO YOU ...IF YOU HAVE ANY DOUBTS PLS COMMENTS BELOW...I WILL BE THERE TO HELP YOU...PLS RATE THUMBS UP...!!

ANSWER::-

as for given data....

Using Localdate Java libraries, write a program that computes
   the number of days between any two dates (inclusive). You must take
   into account leap years. The rule for computing a leap year is as
   follows: If the year is divisible by 4 it is a Leap Year ...
   Unless the year is divisible by 100, then it is _not_ a Leap Year
   ... Unless the year is divisible by 400, then it _is_ a Leap Year.
   
   During a Leap year, an extra day is added at the end of the month
   of Feb.

CODE ::-

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;

public class DaysBetween {
public static void main(String[] args) {

   try {
   if(args.length==2) {
       DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
LocalDate startDate = LocalDate.parse(args[0],formatter);
LocalDate endtDate = LocalDate.parse(args[1],formatter);
Long range = ChronoUnit.DAYS.between(startDate, endtDate);
if(range<0) {
   System.out.println("date 1 is not earlier than date 2");
}else {
   System.out.println(range+" day");
}
  
   }else {
       System.out.println("Please check the command line lengh");
   }
   }catch(Exception e){
       System.out.println("Please give the correct date format as MM/DD/YYYY");
   }

}
}

Running program:
java DaysBetween 03/01/1000 02/29/1000

OUT PUT ::-

date 1 is not earlier than date 2


Run2:
java DaysBetween 11/11/2002 11/12/2002
1 day

THANK YOU...!!

.

Similar Solved Questions

1 answer
2. In households with children, some of the school age children ate school lunches and others...
2. In households with children, some of the school age children ate school lunches and others did not. Hence, we have another random phenomenon. Define a new random variable v as follows: O, if none of the children in household ate school lunch 1, if at least one child in household ate school lunch ...
1 answer
1. Using appropriate properties and the table of Fourier transforms, obtain and sketch the sin(at) Fourier...
1. Using appropriate properties and the table of Fourier transforms, obtain and sketch the sin(at) Fourier transform of the signal x()cn(31-4 marks) 2fX(a), determine the Fourier transform of the signal y(t)dx( F.T. dx(2t) dt (3 marks) 3. Find the Fourier transform of x(t)-cos(2t/4). (3 marks) 4. Le...
1 answer
Connect Quiz 6 A stock had returns of 16 87 percent. -6.63 percent, and 23.63 percent...
Connect Quiz 6 A stock had returns of 16 87 percent. -6.63 percent, and 23.63 percent for the past three years. What is the standard deviation of the returns? Multiple Choice ο ο ο ο ο...
1 answer
True or False: Increases in the market value of a stock generate capital gains when the...
True or False: Increases in the market value of a stock generate capital gains when the stock is sold...
1 answer
Why is there an exception in the ionization energy trend in the second-row p-block elements?
Why is there an exception in the ionization energy trend in the second-row p-block elements?...
1 answer
The prices of the tablets in a store have a mean of $840 and a standard...
The prices of the tablets in a store have a mean of $840 and a standard deviation of $70. Use normcdf on your calculator to find the following probabilities. Express your answers as decimals rounded to three spaces. 1. P (the tablet will be less than $700) = 2.P (the tablet will be between $800 and ...
1 answer
AMS Company has unexpectedly generated a​ one-time extra ​$6 million in cash flow this year. After...
AMS Company has unexpectedly generated a​ one-time extra ​$6 million in cash flow this year. After announcing the extra cash​ flow, AMS stock price was ​$45 per share​ (it has 1 million shares​ outstanding). The managers are considering spending the ​$6 mill...
1 answer
Can you please help with both A and B 0E3 ?
Can you please help with both A and B 0E3 ?...
1 answer
The answer should be 1 and 2, could you draw and label the s and r...
The answer should be 1 and 2, could you draw and label the s and r for each group. I’m getting r for the OH group on number 1, I’m not sure if that’s right. Thanks, will rate and comment! 19. Which of the following structures represent the same stereoisomer? Br нсо...
1 answer
5- In a nationalpark in Texas, vehicles begin to arrive at a parking lot at 7:30...
5- In a nationalpark in Texas, vehicles begin to arrive at a parking lot at 7:30 A.M. with an arrival rate function (in vehicles per minute) of (t) = 4 -0.02t, where t is in minutes. At 7:40 A.M. the parking lot opens and processes vehicles at a rate of 10 per minute. a) (7%) What is the average del...
1 answer
1. Many insurance policies carry a deductible provision that states how much of a claim a...
1. Many insurance policies carry a deductible provision that states how much of a claim a person must pay out of pocket before the insurance company pays the remaining of the expenses. For example, if someone files a claim for $350 on a policy with a $200 deductible, he or she pays $200 and the insu...
1 answer
. Suppose a firm issued a 9% coupon bond (semiannual coupon) 20 years ago. The bond...
. Suppose a firm issued a 9% coupon bond (semiannual coupon) 20 years ago. The bond n ow has 10 years left until its maturity date. The bond is selling at $750. . But the firm is having financial difficulty. Investors believe that the firm will be able to ma ke good on the remaining interest rate pa...
1 answer
A 0.4 kg block rests on a desk. The coefficient of static friction is 0.2. You...
A 0.4 kg block rests on a desk. The coefficient of static friction is 0.2. You push the side of the block but do not have a spring scale to measure the force you use. The block does not move. Which statement is true about the force of static friction ? - It is no larger than 0.78 N - It is 0.78 N - ...
1 answer
6. Sketch the vector a = (-3,5,2) using a rectangilar prism to illustrate perception. [1]
6. Sketch the vector a = (-3,5,2) using a rectangilar prism to illustrate perception. [1]...
1 answer
Answer the following questions in paragraph format. What is the hierarchical pyramid and where are its...
Answer the following questions in paragraph format. What is the hierarchical pyramid and where are its roots? Describe the types of structures used by businesses today? What is formal communication and in which directions can it flow? What are the components of organizational culture? Describe each...
1 answer
The Zagat Restaurant Survey provides food, decor, and service ratings for some of the top restaurants...
The Zagat Restaurant Survey provides food, decor, and service ratings for some of the top restaurants across the United States. For 21 restaurants located in a certain city, the average price of a dinner, including one drink and tip, was $48.60. You are leaving on a business trip to this city and wi...
1 answer
Albert Co. is considering a four-year project that will require an initial investment of $5,000. The...
Albert Co. is considering a four-year project that will require an initial investment of $5,000. The base-case cash flows for this project are projected to be $15,000 per year. The best-case cash flows are projected to be $22,000 per year, and the worst-case cash flows are projected to be -$1,500 pe...