Advertisement
backlight0815

Untitled

Jun 15th, 2022
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.82 KB | None | 0 0
  1. package practise;
  2. import javax.swing.JOptionPane;
  3. public class Practise {
  4.     public static void main(String[] args) {
  5.         String input = JOptionPane.showInputDialog("Enter your birth year: ");
  6.         String inputs = JOptionPane.showInputDialog("Enter your name: ");
  7.         String gender = JOptionPane.showInputDialog("Enter your gender: ");
  8.  
  9.         int year = Integer.parseInt(input);
  10.         int age = 2022-year;
  11.         String name = inputs;
  12.         String genders = gender;
  13.         String Male = "Mr.";
  14.         String Female = "Ms.";
  15.  
  16.         if (gender == Male){
  17.           JOptionPane.showMessageDialog(null, "Mr."  +  name+  age+" years old!");
  18.  
  19.         }else {
  20.                    JOptionPane.showMessageDialog(null, "Ms."  +  name+  age+" years old!");
  21.  
  22.         }
  23.                
  24.        
  25.     }    
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement