Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pkg7.pkg9_ab.diskriminering;
- import java.util.Scanner;
- public class Diskriminering {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- System.out.print("What job are you applying for?\n");
- String job = scan.nextLine();
- System.out.println("Are you a man or a woman? ");
- String gender = scan.next();
- System.out.println("How old are you? ");
- int age = scan.nextInt();
- System.out.println("Do you have any children(true/false)? ");
- boolean kids = scan.nextBoolean();
- int i = 0; //amount of right answers
- String first = "";
- String second = "";
- String third = "";
- if(gender.equals("man")){
- ++i;
- first = "are a man";
- }
- if(age < 30){
- ++i;
- if(first.equals(""))
- first = "are less than 30 years old";
- else
- second = "are less than 30 years old";
- }
- if(kids == false){
- ++i;
- if(second.equals(""))
- second = "do not have kids";
- else
- third = "do not have kids";
- }
- if(i >= 2)
- System.out.print("Since you " +first +(i == 3 ? (", " +third+ ",") : "")+ " and " +second+ " you are qualified to work as a " +job+ "for us.");
- else
- System.out.print("Unfortunately you are not qualified for this job.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement