1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
schepotkina [342]
3 years ago
11

In this lab, you add the input and output statements to a partially completed Java program. When completed, the user should be a

ble to enter a year, a month, and a day to determine if the date is valid. Valid years are those that are greater than 0, valid months include the values 1 through 12, and valid days include the values 1 through 31.
Instructions


Notice that variables have been declared for you.


Write the simulated housekeeping() method that contains input statements to retrieve a year, a month, and a day from the user.


Add statements to the simulated housekeeping() method that convert the String representation of the year, month, and day to ints.
Computers and Technology
1 answer:
leonid [27]3 years ago
8 0

Answer:

import javax.swing.JOptionPane;

public class BadDate {

  private static final int MINIMUM_YEAR = 0, MINIMUM_MONTH = 1, MAXIMUM_MONTH = 12, MINIMUM_DAY = 1, MAXIMUM_DAY = 31;

  private int year = 0;

  private int month = 0;

  private int day = 0;

  public void housekeeping() {

      String yearData = JOptionPane.showInputDialog("Enter year");

      String monthData = JOptionPane.showInputDialog("Enter month");

      String dayData = JOptionPane.showInputDialog("Enter day");

      this.year = Integer.parseInt(yearData);

      this.month = Integer.parseInt(monthData);

      this.day = Integer.parseInt(dayData);

  }

 

  public boolean isLeapYear(){

      if(((this.year % 400) == 0) || (((this.year % 4) == 0) && ((this.year % 100) != 0)))

          return true;

      else

          return false;

  }

  public void endOfJob() {

      boolean validDate = true;

     

      if((month < MINIMUM_MONTH) || (MAXIMUM_MONTH < month))

          validDate = false;

      else {

          if(((month == 1) || (month == 3) || (month == 5) || (month == 7) ||

                  (month == 8) || (month == 10) || (month == 12)) && ((day < 1) || (31 < day)))

              validDate = false;

         

          else if(((month == 4) || (month == 6) || (month == 9) || (month == 11)) && ((day < MINIMUM_DAY) || (30 < day)))

              validDate = false;

         

          else if(month == 2) {

              if(isLeapYear() && ((day < MINIMUM_DAY) || (29 < day)))

                  validDate = false;

              else if((day < MINIMUM_DAY) || (28 < day))

                  validDate = false;

          }

      }

     

      if (validDate) {

          JOptionPane.showMessageDialog(null, "Date: " + this.month + "/" + this.day + "/" + this.year);

          System.out.println(this.month + "/" + this.day + "/" + this.year + " is a valid date");

      } else {

          JOptionPane.showMessageDialog(null, this.month + "/" + this.day + "/" + this.year + " is an invalid date");

          System.out.println(this.month + "/" + this.day + "/" + this.year + " is an invalid date");

      }

  }

  public static void main(String args[]) {

     

      BadDate date = new BadDate();

      date.housekeeping();

      date.endOfJob();

  }

}

Explanation:

  • Take the year, month and day from user  as an input.
  • Check if the year of this date is a leap year inside the isLeapYear method.
  • Inside the housekeeping method , take the year, the month and day  to ensure that date is valid .
  • Display positive response by printing valid date if date is correct.
  • Otherwise alert user that an invalid date was entered.
You might be interested in
Assume that you have been hired by a small veterinary practice to help them prepare a contingency planning document. The practic
nikdorinn [45]

Answer:

Answer explained below

Explanation:

Given: The information provided is given as follows:

  • There is a small veterinary practice which includes the services like office visits, surgery, hospitalization and boarding.
  • The clinic only has a small LAN, four computers and internet access.
  • The clinic only accepts cats and dogs.
  • Hurricanes are the major threatening factor in the geographical region where the clinic is located.
  • The clinic is established in a one-story building with no windows and meet all the codes related to hurricanes.
  • As public shelters do not allow animals to stay when there is a possibility of hurricanes, therefore the clinic does not accept animals for boarding during that time

Contingency planning documents for the tasks given is as follows:

  1. Threat category along with their business impact:
  • Hurricane: It is given that the region where the clinic is located is highly threatened by hurricanes. This type of disaster can affect the life of the employees as well as patients present in the building. Also, in case of a strong hurricane, the building can also be damaged.
  • Preventive measures: Separate shelters can be installed for animals in case of emergency.

  • Fire: In case of fire due to malfunctioning of any electrical equipment or any other reason, there is no window or emergency exit available. It can damage the building and the life of the employees and animals will be in danger.
  • Preventive measures: Services should be provided to all the electrical equipment’s from time to time and emergency exits should be constructed so that there is a way to get out of the building in case the main entrance is blocked due to any reason in the time of emergency.

  • Viral Influenza: If an employee or animal is suffering from any serious viral disease. That viral infection can easily spread to others and make other animals as well as employees sick. If the employees working in the clinic are sick. This will highly affect the efficiency of them which will then affect the business.
  • Preventive measures: This can be avoided by giving necessary vaccines to the employees from time to time and taking care of the hygiene of the patient as well as the clinic which will make the chance of infection to spread low.

  • Flood: In case of a flood like situation, as given the building has only one story and there is no emergency exit for employees and animals to escape. This can put the life of the employees and animals in danger and can affect the working of the clinic as well.
  • Preventive measures: This can be prevented by collecting funds and increasing the story’s in the building or constructing alternate site location so that in case of emergency, the animals or employees can be shifted to other locations.
4 0
4 years ago
What are radio waves and what kinds of Information do they transmit ​
loris [4]

Answer:

Explanation:

Radio waves are a part of electromagnetic waves. They are high wavelength and low frequency waves that are classified as non-ionizing radiation. These waves are mostly used for communication purposes.

Radio waves carry are interpreted by devices that converts them to mechanical energy that can be interpreted and easily discerned. These waves carry a broad range of information.

These waves carry time-varying electrical signals that can easily be transmitted and they are produced by accelerated electrical charges.

4 0
4 years ago
What company was affected by the cloudbleed vulnerability?
DIA [1.3K]

The <em>cloud bleed vuneraliblity</em> describes the security flaw which was discovered in 2017 and had affected internet service company CloudFlare and many websites using the company's services.

CloudFlare is a internet service company which operates to provide security of data to millions of websites. However, a glitch occured during a certain security update which led to a loophole which wasn't discovered for months.

This made the user data on CloudFlare's network susceptible over the course of that period. It was reported that companies such as Uber, OKcupid and several others on the CloudFlare security network were affected.

Therefore, the company affected by the cloud bleed vuneraliblity is CloudFlare.

Learn more :brainly.com/question/25018707

7 0
3 years ago
1. Changing from a major to a minor key signature in a composition can have what effect?
Amanda [17]

1. Answer A.

2. Answer. C.

3. singing.

4.?

5. I believe it would be B! The Melody!

Stand back and look at it in the eyes of someone that's not as music savvy - the thing that truly makes you relax and turn to bliss - is the melody. You tend to focus on it, listen for it.

I hope all is well, and you pass! Good luck, rockstar! (:



3 0
3 years ago
School officials want to show the percentage of students who buy lunch from the school cafeteria compared to the percentage of t
Minchanka [31]

I would say it would be (A pie chart)

6 0
3 years ago
Other questions:
  • You have created a number of different documents using several applications including word, excel, and powerpoint. these files a
    10·1 answer
  • What age group is experiencing the most growth in social media
    13·1 answer
  • Passing by reference is used if a parameter's data flow is A. one-way, into the function. B. one-way, out of the function. C. tw
    13·1 answer
  • What is programming blocks?
    11·1 answer
  • Which tool should be used to verify the compatibility of an application run on Windows 10?
    7·1 answer
  • What is the overall objective of an IT risk assessment? To assist IT management in establishing a budget for countermeasures To
    11·1 answer
  • Who tryna play fortnite?
    5·2 answers
  • What is the function of a breadcrumb trail in a website?
    13·1 answer
  • What is a function in Microsoft Excel?
    5·1 answer
  • When delivering 2023 murano, demonstrate how to turn the driver assistance technologies on or off using ________.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!