Computer Science, asked by devyani49, 2 months ago

please write a method program according to the question in the attachment
: )

Attachments:

Answers

Answered by piyushkumar2231
0

Answer:

import java.util.*;

class Ideone

{

public static void main (String[] args) {

Scanner sc = new Scanner (System.in);

// taking input from user

System.out.println("Enter age");

int age = sc.nextInt();

System.out.println("Enter sex: M/F");

int sex = sc.next().charAt(0);

System.out.println("Are you married? Y/N");

int married = sc.next().charAt(0);

// checking if user is female

if(sex == 'F') {

System.out.println("You will work only in urban areas");

}

// checking if user is male

if(sex == 'M') {

if((age >= 20) && (age < 40)) {

System.out.println("You may work anywhere");

}

else if((age >= 40) && (age < 60)) {

System.out.println("You will work only in urban areas");

}

else {

System.out.println("ERROR");

}

}

}

}

Similar questions