Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package javafunwithdermot;
- import javax.swing.JOptionPane;
- /**
- *
- * @author Dermot
- */
- public class IF_ELSE {
- public static void main(String[] args) {
- try
- {
- int userage = 45;
- if (userage <= 18)
- {
- System.out.println("User is 18 or Younger");
- }
- else if (userage > 18 && userage < 40)
- {
- System.out.println("User is between 19 and 39");
- }
- else if (userage == 45 || userage == 50)
- {
- System.out.println("User is either 45 or 50");
- }
- else
- {
- System.out.println("User is older than 40");
- }
- }
- catch (Exception Ex)
- {
- JOptionPane.showMessageDialog(null,
- Ex.getClass() + "\n\nCause: " + Ex.getMessage() +
- "\n\nError came From Line # " + Ex.getStackTrace()[0].getLineNumber(),
- "ERROR" , JOptionPane.ERROR_MESSAGE);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement