Answer to Question #250145 in Java | JSP | JSF for Drunk

Question #250145
  1. Copy the following java program.
  2. Paste it on the submission textbox then insert useful comments (Use multi-line and single-line comments.)

 

  1. public class IfElseExample {  
  2. public static void main(String[] args) {  
  3.     int number=13;    
  4.     if(number%2==0){  
  5.         System.out.println("even number");  
  6.     }else{  
  7.         System.out.println("odd number");  
  8.     }  
  9. }  
  10. }  
1
Expert's answer
2021-10-12T01:45:00-0400

Source code

//define a class called IfElseExample
public class IfElseExample { 
    //define the main method
    public static void main(String[] args) { 
        /*
        define a variable named number and initialize it to 13
        */
        int number=13; 
        /*
        check the number is divisible by two (even)
        if it is even display "even number" on the screen
        */
        if(number%2==0){  
            System.out.println("even number");  
        }
        /*
        if the number is not divisible by two is even display "odd number" on the screen
        */
        else{  
            System.out.println("odd number");  
        }  
    }  
} 


Output





Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS