Additional Assignment You\'ve been spending so much time learning Java that you\
ID: 3594261 • Letter: A
Question
Additional Assignment You've been spending so much time learning Java that you're concerned you may miss several important dates. Write a class called Reminders that will remind you of the following dates January 1st: new year's day February 2nd: groundhog's day February 14th: valentine's day March 14th: wedding anniversary March 15th: mother's birthday April 15th: tax day July 4th: independence day October 31st: halloween The program should loop through each day of each month (assume that each month has 31 days), check if the date is in the reminder list, and print a reminder message if presentExplanation / Answer
//here is the code for the given question. I have added comments wherever necessary, if you have any doubt with
//this solution do comment. Happy to help!
import java.util.*;
import java.lang.*;
import java.io.*;
import javax.swing.JOptionPane; //import to display message box
class Reminders
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
String mess=""; //initialsie the date String
//enter the data for the various dates
int[][] a={{1,1},{2,2},{14,2},{14,3},{15,3},{15,4},{4,7},{31,10}};
String[] rem={"New Year Day","Groundhog Day","Valentines Day","Wedding Anniversary","Mother Birthday","Tax Day","Independence Day","Halloween"};
for(int i=1;i<=12;i++) //loop for 12 months
{
for(int j=1;j<=31;j++) //loop for 31 days per month
{
for(int k=0;k<8;k++) //loop for all the data
{
if(a[k][1]==i && a[k][0]==j) //if the date matches
{
//store alert message
mess+=Integer.toString(j)+"/"+Integer.toString(i)+" : "+rem[k]+" ";
}
}
}
}
System.out.println(mess); //display the alert message
JOptionPane.showMessageDialog (null,mess, "Reminder", JOptionPane.INFORMATION_MESSAGE); //show the message box witht eh reminders
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.