subject

Writing a Modular Program in Java Summary
In this lab, you add the input and output statements to a partially completed Java program. When completed, the user should be able 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 yearString, a monthString, and a dayString from the user.

Add statements to the simulated housekeeping() method that convert the String representation of the year, month, and day to ints.

Include the output statements in the simulated endOfJob() method. The format of the output is as follows:month/day/year is a valid date. or month/day/year is an invalid date.

Execute the program entering the following date:month = 5, day = 32, year =2014Observe the output of this program.

Execute the program entering the following date:month = 9, day = 21, year = 2002Observe the output of this program.

/* Program Name: BadDate. java 

   Function: This program determi nes if a date entered by the user i s valid.  

   Input:  Interactive

   Output: Valid date is printed  or user is alerted that an invalid  date was entered.

*/  

import java. util. Scanner;

public class BadDate

{

   public static void main(String  args[])

   { 

     // Declare variables

     

     String yearString;

     String monthString;

     String dayString;

     int year;

     int month;

     int day;

     boolean validDate = true;

     final int MIN_YEAR = 0, MIN_ MONTH = 1, MAX_MONTH = 12, MIN_DAY  = 1, MAX_DAY = 31; 

     // This is the work of the h ousekeeping() method

     // Get the year, then the mo nth, then the day

     Scanner input = new Scanner( System. in);

     // variable = input. nextLine();

     

     // Convert Strings to intege rs

     

     // This is the work of the d etailLoop() method

     // Check to be sure date is  valid

     if( year <= MIN_YEAR )  / / invalid year

      validDate = false;

     else if ( month < MIN_MON TH || month > MAX_MONTH )  // in valid month

      validDate = false;

     else if ( day < MIN_DAY | | day > MAX_DAY ) // invalid day

      validDate = false; 

     

     // This is the work of the e ndOfJob() method

     // Test to see if date is va lid and output date and whether it  is valid or not

     if( validDate == true )

     { 

   // Output statement 

     }

     else

     {

   // Output statement 

   

     }

     

   } // end of main() method

} // end of BadDate class 

      

      

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 18:10
For each of the following claims, determine whether they are true or false. justify your determination (show your work). if the claim is false, state the correct asymptotic relationship as o, θ, or ω. unless otherwise specified, lg is log2.(a) (b) (c) (d) (e) (f) (g) (h) (i) (j)n+1 =22n =2n =1 =ln2 n =n2 +2n−4 =33n = 2n+1 =√n = 10100 =o(n4) o(2n)θ(2n+7 ) o(1/n)θ(lg2 n) ω(n2 )θ(9n ) θ(2n lg n )o(lg n) θ(1)
Answers: 1
question
Computers and Technology, 22.06.2019 00:00
Match each vocabulary word to its definition.1. desktoppicture used to represent acomputer application2. domainnetwork protectionsoftware code that can be viewed,3. iconmodified, and redistributed for freethe background screen on acomputer monitor4. url5. blogan online journalthe part of an internet address that6. firewallrefers to a group of computers on anetworkonline database of web pages7. intranetnetwork for use by an individual8. open address of a web page or9. wikiresource
Answers: 2
question
Computers and Technology, 22.06.2019 10:20
Shown below is the start of a coding region within the fist exon of a gene. 5'--3' 3'--5' how many cas9 pam sequences are present?
Answers: 1
question
Computers and Technology, 22.06.2019 16:30
You have inserted new slides based on a word outline. how do you format these new slides to match the powerpoint presentation formatting? a. select all slides in the presentation and click format on the home tab. b. select the new slides and click reset on the home tab. c. select all slides in the presentation and click reset on the home tab. d. select the new slides and click format on the home tab.
Answers: 2
You know the right answer?
Writing a Modular Program in Java Summary
In this lab, you add the input and output statemen...
Questions
question
Mathematics, 25.09.2019 20:00
Questions on the website: 13722360