well i have another assignment due, and i think i am getting the hang of things
what i have to do is determine whether when a user inputs a specific date, if that date is a school day or not
here is the code i have now
import javax.swing.JOptionPane;
public class asgn2 {
public static void main(String args[]) {
String numString = JOptionPane.showInputDialog(null,
"Pick a month!! (1-12):", "Input Window Demo",
JOptionPane.QUESTION_MESSAGE);
String dayString = JOptionPane.showInputDialog(null,
"Pick a day!! (1-31):", "Input Window Demo",
JOptionPane.QUESTION_MESSAGE);
// Convert the string into an int value
int month = Integer.parseInt(numString);
System.out.print("The date you entered is ");
switch ( month ) {
case 1:
System.out.print("January " + dayString + "\n" );
break;
case 2:
System.out.print("February " + dayString + "\n" );
break;
case 3:
System.out.print("March " + dayString + "\n" );
break;
case 4:
System.out.print("April " + dayString + "\n" );
break;
case 5:
System.out.print("May " + dayString + "\n" );
break;
case 6:
System.out.print("June " + dayString + "\n" );
break;
case 7:
System.out.print("July " + dayString + "\n" );
break;
case 8:
System.out.print("August " + dayString + "\n" );
break;
case 9:
System.out.print("September " + dayString + "\n" );
break;
case 10:
System.out.print("October " + dayString + "\n" );
break;
case 11:
System.out.print("November " + dayString + "\n" );
break;
case 12:
System.out.print("December " + dayString + "\n" );
default:
System.out.print("That month does not exist you fool! \n");
} // end switch
System.exit( 0 ); // terminate application
} // end main
}
according to the assignment:
The student should be prompted to enter an integer for the month and then prompted to enter an integer for the day. (For example, entering "2" for the month and "14" for the day would represent February 14th.) (WHICH I HAVE DONE ALREADY)
The program will tell the student if that date is a vacation day and if so, which one, by printing out a message such as:
February 18 is Presidents' Day.
If the day selected is not a holiday, the program should print out a message such as:
February 17 is not a school holiday.
Now for the second part, i am pretty sure i have to do an if/else statement, but how would i get that to display or compile since i have 2 different variables? would it be something like
case 1:
System.out.print("January " + dayString + "\n" );
break;
if dayString + numString == January 8
else System.out.print("January" + dayString + " is a holiday";
i know thats not right, but am i somewhat close?
thanks in advance