Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This lab is based around the creation and use of methods involving if statements inside a Class to determine if a date the user types

image text in transcribedimage text in transcribed

This lab is based around the creation and use of methods involving "if" statements inside a Class to determine if a date the user types in is valid. At the start of this lab, you will create a number of methods that can be called on in later methods and programs, all of which will need to use "if" statements and not case/switch statements. This lab will be built in a Java Project called Assignment7 and Class called DateCheckProgram Please note that if I specify that you are to use a previously created method, you must use it in order to get credit. Also, you are only to use "if" statements in this lab, not case/switch statements. Any text indicated by bold red writing, indicates what the code should print out in order to receive full credit for your code. Any text indicated by blue bold writing means that this is an example of user input. Methods 1. Public static int daysInTheYear This method should take in one integer parameter/input that will represent a year (2005, 2019, etc.). The method should return an int representing the number of days in the input/parameter year. This can be determined by using the steps shown in Figure 1. 1. If the year is evenly divisible by 4, go to step 2. Otherwise, go to step 5. 2. If the year is evenly divisible by 100, go to step 3 Otherwise, go to step 4 3. If the year is evenly divisible by 400, go to step 4 Otherwise, go to step 5 4. The year is a leap year (366 days) 5. The year is not a leap year (365 days) Figure 1: A figure showing the steps to determine the amount of days in a certain year Note: This can be accomplished by either nesting "if"' statements or creating a temporary value and using it to determine the results of the next "if" statements. 2. Public static int writtenMonthToNumericMonth This method should take in one String as an input/parameter that represents the name of the month. It will translate the written form of a month into the numeric form and return that value ("June">6, "December"->12). If the String is not a valid month, the method should return an int value of '13' 3. Public static int validDateCheck This method should take in three ints as a parameter/input, one representing a month, one representing a day, and one representing a year (four digits). Taking these parameters into account, this method will return a value of'1' if the date is valid and will return a '0' if the date is invalid. Note that you must account for the possibilities of leap years by using a previous method in this method 4. Public static void printValidDateCheckResults This method should take in an int as a parameter/input, representing the results of if a date is valid. If the input/parameter is '1', the method should print "The date you have entered is valid." Otherwise, the method should print, "The date you have entered is not valid." 5. Public static void main(Stringll args) In the main section of the code, the user should be prompted to enter a numeric day of the year, type out the name of the month, and enter the numeric yearly date. Using the previously typed information, the program should determine whether the date the user typed in is valid and print out a related message to the console. The output should look like what is shown irn Figure 2 Valid Date Checker Please Type In A Day Of The Month 14 Please Type In The Name Of The Month June Please Type In The Year: 2015 Outcome The date you have entered is valid Valid Date Checker Please Type In A Day Of The Month 29 Please Type In The Name Of The Month February Please Type In The Year 2012 Outcome The date you have entered is valid Valid Date Checker Please Type In A Day Of The Month 14 Please Type In The Name Of The Month Antil Please Type In The Year: 2015 Outcome The date you have entered is not valid Valid Date Checker Please Type In A Day Of The Month Please Type In The Name Of The Month February Please Type In The Year: 2017 Outcome The date you have entered is not valid Figure 2: Four sample outputs that display what the program should print into the console when compiled. Once all methods are completed, check to make sure that you are following all of the guidelines in the coding standards for this class (indenting, commenting, headers, method headers). After fully finishing, save the .java file to submit on eCampus

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Image Databases Towards Advanced Image Retrieval

Authors: Yihong Gong

1st Edition

1461375037, 978-1461375036

More Books

Students also viewed these Databases questions