Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CalenderDate Program im needing to validate the user inputted date and should the date be invalid i must return January 1,2012 as the default date.

CalenderDate Program
im needing to validate the user inputted date and should the date be invalid i must return January 1,2012 as the default date. I also need to return the day of the week that the user inputted date lands on in string form.
image text in transcribed
image text in transcribed
here is my output:
image text in transcribed
7 package calenderDate; 8 9 import java.util.; 10 11 public class Calender Date 12 Strine monthNome - (January", "February", "March","April", "May", "June", "uly","August", "September", "October, November December"): 15 int; 16 int da; 17 int yy: 18 private GregorianCalendar calen, 19 200 public static void main(String[] args) 21 22 Calender Date Date: 12 Scanner scan = new Scanner(System.in); 24 25 System.out.println("Please enter any valid date."): 2 int month - scan.nextInt(); 27 int day scan.nextInt(); int year - scan.nextInt(); 29 Date - new Calender Date(month,day, year); 30 31 System.out.println("Date: Oate.toStrine()); 32 System.out.println("Next Date: Date.nextDate()); System.out.println("Previous Date: Date.prevDate(); 16 System.out.println("The day of the week is: "Date.dayofweek()); 18 public Calender Date(int mint dd, int y) calen-new GregorianCalendar (yy, dd); CalenderDate.java 410 public Calender Date(int n, int da, int yy) 42 calen- new GregorianCalendar(yy.m, dd) 3 44 45 public String nextDate() 46 String next": 47 calen.add(GregorianCalendar.DAY_OF_MONTH, 1); 18 String month monthName[calen.get(Calendar.MONTH)-1]; 19 next month.".".calen.get(Calendar DAY_OF_MONTH) 1.calen.cet(Calendar. YEAR); 61 return next; 2 } 4 public String prevDate() String next:""; calen.add(GregorianCalendar.DAY_OF_MONTH, 2); String month - monthName(calen.get(Calendar.MONTH)-11 next month.",".calen.get(Calendar.DAY_OF_MONTN)".calen.set(Calendar. YEAR); return next; public Strine toString() String date": String month monthName(calen.get(Calendar. MONTH) - 1); date month",".calen.get(Calendar.DAY_OF_MONTH)+".".calen.set(Calendar. YEAR); return date; public int dayofweek) int dayofweek cxlen.set(Calendar.DAY_OF_WEEK); return dayofweek; ram Please enter any valid date. 9 24 2020 Date: September, 24,2020 Next Date: September 25, 2020 Previous Date: September, 23, 2020 The day of the week is: 6

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_2

Step: 3

blur-text-image_3

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

Database Processing

Authors: David M. Kroenke, David Auer

11th Edition

B003Y7CIBU, 978-0132302678

More Books

Students also viewed these Databases questions

Question

=+6. What does the invisible hand of the marketplace do?

Answered: 1 week ago

Question

=+ 4. Why should policymakers think about incentives?

Answered: 1 week ago