Wednesday, August 3, 2022

Days of the Month Using Swing in Java

 Machine Problem

Create a program that will input a value of days and output  the corresponding number of months and number of days.  Assume that 30 days is equivalent to 1 month.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

Please subscribe to my channel  https://www.youtube.com/channel/UCOs-lpOoIeJoh6gpJthPoGg

=================================================


Want to support my channel?

GCash Account

Jake Pomperada


09173084360


Paypal

https://paypal.me/jakerpomperada


Patreon

https://www.patreon.com/jakerpomperada


Thank you very much for your support.



Program Listing


/* Create a program that will input a value of days and output

 * the corresponding number of months and number of days. 

 * Assume that 30 days is equivalent to 1 month.

 * 

 */


import javax.swing.JOptionPane;


public class Month {


public static void main(String[] args) {

// TODO Auto-generated method stub

// obtain user input from JOptionPane input dialogs


      String days = 


         JOptionPane.showInputDialog( "Enter number of days : " );

      

      int days_value = Integer.parseInt(days); 

      

            

      if (days_value == 28 || days_value == 29) {

        JOptionPane.showMessageDialog( null,  "Month With 28 or 29 Days " + "\nFebruary" 

        , "The Result", JOptionPane.INFORMATION_MESSAGE );

            

      } else if (days_value == 31) {

      JOptionPane.showMessageDialog( null,  "Months With 31 Days\n" + "\nJanuary\r\n"

      + "March\r\n"

      + "May\r\n"

      + "July\r\n"

      + "August\r\n"

      + "October \r\n"

      + "December" 

          , "The Result", JOptionPane.INFORMATION_MESSAGE );

      } else if (days_value == 30) {

      JOptionPane.showMessageDialog( null,  "Months With 30 Days\n" + "\nApril\r\n"

      + "June\r\n"

      + "September\r\n"

      + "November\r\n"

      , "The Result", JOptionPane.INFORMATION_MESSAGE );

      } else {

      JOptionPane.showMessageDialog( null,"Invalid Days. Try Again", 

      "The Result", JOptionPane.INFORMATION_MESSAGE );

      }


}


}




No comments:

Post a Comment