Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package formalgreeting;
- import javax.swing.JOptionPane;
- import java.lang.String;
- public class FormalGreeting {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- String name = JOptionPane.showInputDialog("Enter your name and title");
- if (name.startsWith( "Mr") == true) {
- System.out.print("Hello, sir.");
- } else if (name.startsWith( "Ms") == true || name.startsWith( "Miss") == true ||name.startsWith( "Mrs") == true) {
- System.out.print("Hello, ma'am.");
- } else {
- System.out.print("Hello, " + name);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment