Advertisement
Fakhru

Untitled

Aug 16th, 2014
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5. package javaapplication1;
  6.  
  7. /**
  8. *
  9. * @author user
  10. */
  11. import java.util.Scanner;
  12. public class PikiClass {
  13. public static void main (String[] args) {
  14. String fname,lname,gender,married;
  15. int age;
  16. Scanner input = new Scanner(System.in);
  17. System.out.print("What is your gender? (M/F) ");
  18. gender = input.next();
  19. System.out.println("What is your first name? ");
  20. fname = input.next();
  21. System.out.println("What is your last name? ");
  22. lname = input.next();
  23. System.out.println("What is your age? ");
  24. age = input.nextInt();
  25. if(age >= 20){
  26. if(gender.equals("F") || gender.equals("f")){
  27. System.out.println("Are you married? (Y/N) ");
  28. married = input.next();
  29. if(married.equals("Y") || married.equals("y")){
  30. System.out.println("Hello Mrs."+fname+" "+lname);
  31. }else {
  32. System.out.println("Hello Ms."+fname+" "+lname);
  33. }
  34. }else {
  35. System.out.println("Hello Mr."+fname+" "+lname);
  36. }
  37. }else{
  38. System.out.println("Hello "+fname+" "+lname);
  39. }
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement