For full functionality of this site it is necessary to enable JavaScript. Here are the instructions how to enable JavaScript in your web browser.

All for Joomla All for Webmasters
Close

Java: Random month

package chapter3_3_4;

/**
 *
 * @author Siavash Bakhshi
 */
public class Chapter3_3_4 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        int Min = 0;
        int Max = 12;
        int month = (Min + (int)(Math.random() * (Max - Min)));
         switch (month){
             case 0: System.out.println("January"); break;
             case 1: System.out.println("February"); break;
             case 2: System.out.println("March"); break;
             case 3: System.out.println("April"); break;
             case 4: System.out.println("May"); break;
             case 5: System.out.println("June"); break;
             case 6: System.out.println("July"); break;
             case 7: System.out.println("Augest"); break;
             case 8: System.out.println("September"); break;
             case 9: System.out.println("October"); break;
             case 10: System.out.println("November"); break;
             case 11: System.out.println("December"); break;
             default: System.out.println("Unknown month!");
         }
    }
    
}
Java: Random month (734 downloads )