Question

THE PROBLEM:

It makes it easier if you use switch statements for some part of the homework. Write a program that inputs a month, day, and year from the user and outputs the corresponding date in the following two standard date formats:

6/12/2005  June  12,2005

Also your program must print the name of any holiday associated with the date.

For example:

3/17/2010  March 17, 2010  St. Patrick's Day 

Your program should ask the user how many times the user wants to run the code and then you need to use a for loop to repeat the run that many times.


REQUIREMENTS:

- You must use good programming style.

- The user can enter the month either as a numeric value or a String. i.e. the user could enter a 5 or May.

- You may assume the data that the user enters is valid data.

- Your program must print a report similar to that shown in the sample output on the last page of this handout.

- Provide block comments including your name, date and a description of the program

- Provide comments throughout your code.

- You must create two different classes. DateInput.java and DateInputDriver.java

- You must solve this problem by implementing and using the following methods in the class DateInput.java:


THE PROBLEM: It makes it easier if you use switch statements for some part of the homework. Write a program that inputs a mon

4. getHoliday This method has 2 int type parameters for month and day. The method returns a String that is the name of a holi


use java please


1 0
Add a comment Improve this question Transcribed image text
Answer #1

public void data function(){

void printDirections(){
System.out printIn("This program will take input a month ,day and year and output date in following formats : 6/12/2005 ,June 12,2005 and also will print holidays");
}
String getMonth String(int month){
switch(month){
case 1:
return "Jan";break;
case 2:
return "Feb";break;
case 3:
return "March";break;
case 4:
return "April";break;
case 5:
return "May";break;
case 6:
return "June";break;
case 7:
return "July";break;
case 8:
return "August";break;
case 9:
return "September";break;
case 10:
return "October";break;
case 11:
return "November";break;
case 12:
return "December";break;

Default:
return "INVALID";}}

int getMonthNumber(string month){

switch(month)
case="Jan":
return 1 ; break;
case="Feb":
return 2 ;break;
case ="March":
return 3;break;
case= "April":
return 4; break;
case ="May":
return 5; break;
case="June":
return 6; break;
case="July":
return 7;break;
case="August":
return 8;break;
case="September":
return 9;break;
case="October":
return 10; break;
case="Novermber":
return 11;break;
case="December":
return 12;break;
Default :
return 0;
}}
String getHoliday(int mon,int day){
switch (mon)
{
case 5:
{
switch (day)
case 2:
return "Its my birthday";
}
switch (mon)
{
case 2:
switch (day)
case 12:
return "Abraham Lincoln Birthday";
}

switch (mon)
{
case 1:
switch (day)
case 1:
return "Martin Luther King Birthday";
}

switch (mon)
{
case 12:
switch (day)
case 1:
return "New Year";
}

switch (mon)
{
case 4:
switch (day)
case 1:
return "Ground Hog day";
}
Default :
return " ";

}

boolean isEaster(int mo,int day,int year){

int easterDay,easterMonth,goldennumber,a,b,c,d;
goldennumber=(year%19)+1;
a=(24+19*(goldennumber-1))%30;
b=a-a/28;
c=(year+year/4+b-13)%7;
d=b-c;
easterMonth=3+(d+40)/44;
easterDay=d+28-31*(easterMonth/4);

}


}
class Main {
public static void main(String[] args) {
System.out.println("How many times program should run");
int loop=0;
scanner obj =new scanner(system.in);
loop=obj.nextInt();
for(int i=0;i //now we will call the function here
datafunction();
}  
}
}

Mainjava public void data function ( ) { 1 Enter the Date: 12 va printDirect ions ( ) { void System.out printIn (This progra

COMMENT DOWN FOR ANY QUERIES AND,

LEAVE A THUMBS UP IF THIS ANSWER HELPS YOU.

Add a comment
Know the answer?
Add Answer to:
Write a program that inputs a month, day, and year from the user and outputs the corresponding date in the following two standard date formats:
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program that prompts the user to enter a person's birth date in numeric form...

    Write a program that prompts the user to enter a person's birth date in numeric form (e.g. 8-27-1980) and outputs the date of birth in the format of month day, year (e.g. August 27, 1980). Your program must work for three types of exceptions - invalid day, invalid month and invalid year (year must be between 1915 and 2015). Make these as class driven exceptions. Use one try-catch block with separate catches for the exception classes to handle errors for...

  • IN PYTHON, Write a program that reads a string from the user containing a date in...

    IN PYTHON, Write a program that reads a string from the user containing a date in the form mm/dd/ yyyy. It should print the date in the form April 12, 2017. Hint: Get the "mm" from the user entered date "mm/dd/yyyy", then convert the "mm" into a month number. You may use an list month_list = ['January', 'February','March','April', 'May','June', 'July','August', 'September', 'October', 'November', 'December']. Use the month number you got from "mm" to get the month name.

  • use python Write a program that asks the user for day and month of a birthday....

    use python Write a program that asks the user for day and month of a birthday. The program then tells the Zodiac signs that will be compatible with that birthday. #Example for Aries The Ram    Mar. 21–Apr. 19 day = 24 # user enters this month = 3 # user enters this if ( month == 3 and day >=21) or (month == 4 and day <= 19): print("You are Aries, Fire group, compatible with Aries, Leo, Sagittarius") Zodiac Signs:...

  • CODING IN JAVA Dates are printed in several common formats. Two of the more common formats...

    CODING IN JAVA Dates are printed in several common formats. Two of the more common formats are: 07/21/55 and July 21, 1955 Write a program that reads a date in the first format and prints that date in the second format. Prompt the user and accept user input for the date in MM/DD/YYYY format. Retrieve the month portion of the date entered and convert it to an integer. Do the same thing for day and year Create a string named...

  • Write a program that accepts a date from the user in the form mm/dd/yyyy

    # C PROGRAMMING LANGUAGEWrite a program that accepts a date from the user in the form mm/dd/yyyy and then dis- plays it in the form month dd, yyyy, where month is the name of the month: Enter a date (mm/dd/yyyy): 2/17/2011 You entered the date February 17, 2011 Store the month names in an array that contains pointers to strings.

  • Part I Create a Java program that inputs a grade from the user. The grade input...

    Part I Create a Java program that inputs a grade from the user. The grade input from the user will be an integer. Once the input is stored, use an if-else-if block of code to determine the letter grade of the inputted integer grade. Do not use a bunch of if statements by themselves to solve this problem. You will print an error message for inputs greater than 100 and for inputs less than 0. Both errors must be handled...

  • Write a program named CheckMonth2 that prompts a user to enter a birth month and day....

    Write a program named CheckMonth2 that prompts a user to enter a birth month and day. Display an error message that says Invalid date if the month is invalid (not 1 through 12) or the day is invalid for the month (for example, not between 1 and 31 for January or between 1 and 29 for February). If the month and day are valid, display them with a message. For example, if the month entered is 2, and the day...

  • Write a Java program for a fortune teller. The program should begin by asking the user...

    Write a Java program for a fortune teller. The program should begin by asking the user to enter their name. Following that the program will display a greeting. Next, the program will ask the user to enter the month (a number 1-12) and day of the month (a number 1-13) they were born. Following that the program will display their zodiac sign. Next, the program will ask the user their favorites color (the only choices should be: red, green and...

  • Write program that prompts the user to enter a person's date of birth in numeric form...

    Write program that prompts the user to enter a person's date of birth in numeric form such as 8-27-1980. The program then outputs the date of birth in the form: August 27, 1980. Your program must contain at least two exception classes: invalidDay and invalidMonth. If the user enters an invalid value for day, then the program should throw and catch an invalidDay object. Similar conventions for the invalid values of month and year. (Note that your program must handle...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT