Write a program that demonstrate if-else statement

Category : Java | Sub Category : Control Statement | By Runner Dev Last updated: 2020-09-28 19:13:33 Viewed : 209


(Control Statement)

Write a program that demonstrate if-else statement

Source Code: IfElse.java

/**

 * Write a programme that demonstrate if-else statement

 */

public class IfElse { // This line daclare a new class & the class defination is start.

     public static void main(String a[]) { // This line begins the main() method.

           int month = 4; // April

           String season; // daclare a string name season.

           if (month == 12 || month == 1 || month == 2)

                season = "winter"; // if above condition is true than print winter.

           else if (month == 3 || month == 4 || month == 5)

                season = "Spring"; // if above condition is true than print Spring.

           else if (month == 6 || month == 7 || month == 8)

                season = "Summer"; // if above condition is true than print Summer.

           else if (month == 9 || month == 10 || month == 11)

                season = "Auntumn"; // if above condition is true than print Auntumn.

           else

                season = "Bogus Month"; //

           System.out.println("April is in the " + season + ".");

// this print the season of month.

     } // end of main programme

}

Output: April is in the Spring.




Search
Related Articles

Leave a Comment:
actioky
at 2022-04-20 12:19:31
[url=https://bestadalafil.com/]generic cialis no prescription[/url] Kukkiq cialis levitra pfizer Side effects of high levels of PEEP Barotrauma injury to airway pneumothorax Low cardiac output due to decreased venous return especially in setting of hypovolemiaPEEP like any form of positive intrathoracic pressure lowers venous return and increases pulmonary vascular resistance. Muajzy <a href="https://bestadalafil.com/">Cialis</a> https://bestadalafil.com/ - cialis Viagra Discount Tpnpva