Question

Need this program in Java Develop (using C++ or Java language) the software application described below....

Need this program in Java

Develop (using C++ or Java language) the software application described below.

Write a program that prints the day number of the year, given the date is in the form month-day-year.

For example, if the input is 1-1-09, the day number is 1; if the input is 12-25-09, the day number is 359. The program should check for a leap year. A year is a leap year if it is divisible by 4 but not divisible by 100.

For example, 1992 and 2008 are divisible by 4 but not by 100. A year that is divisible by 100 is a leap year if it is also divisible by 400.

For example 1600 and 2000 are divisible by 400, so they are leap years. However, 1800 is not a leap year because 1800 is not divisible by 400.

Homework Answers

Answer #1

Here is the code for your guven problem, just copy paste and enjoy.

import java.util.*;
import java.lang.*;
import java.io.*;
class dayOfTheYear
{
   public static void main (String[] args)
   {
       System.out.println("Please input the date in MM DD YYYY format: ");
       Scanner in=new Scanner(System.in);
       int MM=in.nextInt();
       int DD=in.nextInt();
       int YYYY=in.nextInt();
       MM--;
  
   int DOY;
   if(MM%2!=0)
{
   if(MM<=7)
   DOY=31*MM;
   else
   DOY=30*MM;
  
}
else
{
   if(MM==2)
  
   DOY=28*MM;
  
else
{
   if(MM>=8)
   DOY=31*MM;
   else
   DOY=30*MM;
}

}
if((YYYY % 400 == 0) || (YYYY % 4 == 0) && (YYYY % 100 != 0)){
if(MM>=1)
DOY+=DD+1;
else
DOY+=DD;
}
else
DOY+=DD;
  
System.out.println("Today is "+DOY+"th day of the year");
  
}

}

if you like this answer, please give a thumbs up and if you have some doubt just ask in the comment section below. I will try to help. Cheers

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Leap Year The month of February normally has 28 days. But if it is a leap...
Leap Year The month of February normally has 28 days. But if it is a leap year, February has 29 days. Write a program that asks the user to enter a year. The program should then display the number of days in February that year. Use the following criteria to identify leap years: Determine whether the year is divisible by 100. If it is, then it is a leap year if and if only it is also divisible by 400....
In this Java programming assignment, you will practice using selection statements to determine whether a given...
In this Java programming assignment, you will practice using selection statements to determine whether a given year in the past or future qualifies as a “Leap Year”. I. Design a class called LeapYear in a file called LeapYear.java. This class will hold the main method and the class method that we will write in this assignment. II. Write an empty public static void main(String[] args) method. This method should appear inside the curly braces of the LeapYear class. III. Write...
In Java or  C++ Develop a simulation program to simulate an 8-port Ethernet switch. The switch initially...
In Java or  C++ Develop a simulation program to simulate an 8-port Ethernet switch. The switch initially has no knowledge about the hosts connected to each port. It learns frame addresses and stores-and-forwards the frames. The input text file "in.txt" contains information of the incoming frames, one frame per line. There are 4 pieces of data per line: frame ID, arrival port, frame source address, and frame destination address. The frames arrive at the switch in the order of which they...
Classes/ Objects(programming language java ) in software (ATOM) Write a Dice class with three data fields...
Classes/ Objects(programming language java ) in software (ATOM) Write a Dice class with three data fields and appropriate types and permissions diceType numSides sideUp The class should have A 0 argument (default) constructor default values are diceType: d6, numSides: 6, sideUp: randomValue 1 argument constructor for the number of sides default values are diceType: d{numSides}, sideUp: randomValue 2 argument constructor for the number of sides and the diceType appropriate accessors and mutators *theoretical question: can you change the number of...
For Java For this assignment you will develop two classes called ATM and Customer that simulate...
For Java For this assignment you will develop two classes called ATM and Customer that simulate an imaginary automated teller machine (ATM). In the assignment, you should also develop a UML class diagram for the ATM class and a jUnit test case. In the program, we assume that an ATM initially keeps $100.00 cash for customer transactions. Additionally, we assume that there are a total of ten customers combined for the Union Bank and BOA banks. This is a list...
***Programming language is Java. After looking at this scenario please look over the requirements at the...
***Programming language is Java. After looking at this scenario please look over the requirements at the bottom (in bold) THIS IS ALL THAT WAS PROVIDED. PLEASE SPECIFY ANY QUESTIONS IF THIS IS NOT CLEAR (don't just say more info, be specific)*** GMU in partnership with a local sports camp is offering a swimming camp for ages 10-18. GMU plans to make it a regular event, possibly once a quarter. You have been tasked to create an object-oriented solution to register,...
A loan made on March 14 is due September 13 of the following year. Find the...
A loan made on March 14 is due September 13 of the following year. Find the exact time for the loan in a​ non-leap year and a leap year. days. The exact time in a​ non-leap year is ? days The exact time in a leap year is ? days. Data Table Sequential Numbers for Dates of the Year Day of Month Jan. Feb. Mar. Apr. May June July Aug. Sept. Oct. Nov. Dec. 1 1 32 60 91 121...
Review the Robatelli's Pizzeria Case Study. Develop another internal controls system, but this time, in the...
Review the Robatelli's Pizzeria Case Study. Develop another internal controls system, but this time, in the purchases and fixed assets business areas. Prepare a 12- to 16-slide presentation describing the purchases and fixed assets business areas. Be sure to incorporate speaker notes as well as appropriate visuals, graphics, fonts, etc. Include any associated risk in these areas. Describe specific internal controls that include authorization of transactions, segregation of duties, adequate records and documentation, security of assets, and independent checks and...
Using the model proposed by Lafley and Charan, analyze how Apigee was able to drive innovation....
Using the model proposed by Lafley and Charan, analyze how Apigee was able to drive innovation. case:    W17400 APIGEE: PEOPLE MANAGEMENT PRACTICES AND THE CHALLENGE OF GROWTH Ranjeet Nambudiri, S. Ramnarayan, and Catherine Xavier wrote this case solely to provide material for class discussion. The authors do not intend to illustrate either effective or ineffective handling of a managerial situation. The authors may have disguised certain names and other identifying information to protect confidentiality. This publication may not be...
Exploring Innovation in Action Power to the People – Lifeline Energy Trevor Baylis was quite a...
Exploring Innovation in Action Power to the People – Lifeline Energy Trevor Baylis was quite a swimmer in his youth, representing Britain at the age of 15. So it wasn’t entirely surprising that he ended up working for a swimming pool firm in Surrey before setting up his own company. He continued his swimming passion – working as a part-time TV stuntman doing underwater feats – but also followed an interest in inventing things. One of the projects he began...