GUI (Swing) Based Season Identifier Java Program
import javax.swing.JOptionPane;
class SeasonIdentifier{
public static void main(String[]args) throws Exception{
String season = JOptionPane.showInputDialog("Enter season number");
int asd = Integer.parseInt(season);
if(asd == 1 || asd == 11 || asd == 12)
JOptionPane.showMessageDialog(null, "The Number: " + asd + "\n Wellcome to WINTER season");
if(asd == 2 || asd == 3 || asd == 4)
JOptionPane.showMessageDialog(null, "The Number: " + asd + "\n Wellcome to SPRING season");
if(asd == 5 || asd == 6 || asd == 7)
JOptionPane.showMessageDialog(null, "The Number: " + asd + "\n Wellcome to SUMMER season");
if(asd == 8 || asd == 9 || asd == 10)
JOptionPane.showMessageDialog(null, "The Number: " + asd + "\n Wellcome to AUTUMN season");
if(asd < 1 || asd > 12)
JOptionPane.showMessageDialog(null, "Invalid Month Number");
}
}
No comments:
Post a Comment