JNET

Programming Activity 3.17 Java Programming 2017

Oct 6th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. import javax.swing.*;
  2.  
  3. public class dialogbox
  4. {
  5. public static void main(String [] args)
  6. {
  7. String name = JOptionPane.showInputDialog(null,
  8. "Please enter your name");
  9. JOptionPane.showMessageDialog(null, "Hello, " + name);
  10.  
  11. String year = JOptionPane.showInputDialog(null, "In what year were you born? ");
  12. int age = 2017 - Integer.parseInt( year );
  13. JOptionPane.showMessageDialog(null, "This year, you will be " + age);
  14. double lived = age/80.0 * 100.0;
  15. JOptionPane.showMessageDialog(null, "You have lived " + lived + "% of your life.");
  16. }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment