Monty374

FormalGreeting

Oct 5th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. package formalgreeting;
  2.  
  3. import javax.swing.JOptionPane;
  4. import java.lang.String;
  5.  
  6. public class FormalGreeting {
  7.  
  8. /**
  9. * @param args the command line arguments
  10. */
  11. public static void main(String[] args) {
  12. String name = JOptionPane.showInputDialog("Enter your name and title");
  13. if (name.startsWith( "Mr") == true) {
  14. System.out.print("Hello, sir.");
  15. } else if (name.startsWith( "Ms") == true || name.startsWith( "Miss") == true ||name.startsWith( "Mrs") == true) {
  16. System.out.print("Hello, ma'am.");
  17. } else {
  18. System.out.print("Hello, " + name);
  19. }
  20.  
  21. }
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment