Advertisement
Guest User

Untitled

a guest
Sep 19th, 2016
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. package pkg7.pkg9_ab.diskriminering;
  2. import java.util.Scanner;
  3.  
  4. public class Diskriminering {
  5. public static void main(String[] args) {
  6. Scanner scan = new Scanner(System.in);
  7.  
  8. System.out.print("What job are you applying for?\n");
  9. String job = scan.nextLine();
  10. System.out.println("Are you a man or a woman? ");
  11. String gender = scan.next();
  12. System.out.println("How old are you? ");
  13. int age = scan.nextInt();
  14. System.out.println("Do you have any children(true/false)? ");
  15. boolean kids = scan.nextBoolean();
  16. int i = 0; //amount of right answers
  17. String first = "";
  18. String second = "";
  19. String third = "";
  20.  
  21. if(gender.equals("man")){
  22. ++i;
  23. first = "are a man";
  24. }
  25. if(age < 30){
  26. ++i;
  27. if(first.equals(""))
  28. first = "are less than 30 years old";
  29. else
  30. second = "are less than 30 years old";
  31. }
  32. if(kids == false){
  33. ++i;
  34. if(second.equals(""))
  35. second = "do not have kids";
  36. else
  37. third = "do not have kids";
  38. }
  39.  
  40. if(i >= 2)
  41. System.out.print("Since you " +first +(i == 3 ? (", " +third+ ",") : "")+ " and " +second+ " you are qualified to work as a " +job+ "for us.");
  42. else
  43. System.out.print("Unfortunately you are not qualified for this job.");
  44. }
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement