Answer to Question #316822 in Java | JSP | JSF for Dunga

Question #316822

Write a Java program that prompts the user to enter thier gender ( Female/ male) and day of the week ( Monday to Sunday). If you enter Monday, or Tuesday, or Wednesday or Thursday it should read "Hello sir, enjoy your day" or "Hello mam enjoy your day". But when entered Friday, or Saturday, or Sunday it should read "Hello sir enjoy your weekend" or "Hello mam enjoy your weekend "

1
Expert's answer
2022-03-23T13:44:36-0400
import java.util.*;
public class Test {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        String gender;
        String day;
        System.out.print("Enter your gender: ");
        gender = scan.nextLine();
        System.out.print("Enter day of the week: ");
        day = scan.nextLine();
        if (day.equals("Monday") || day.equals("Tuesday") || day.equals("Wednesday") || day.equals("Thursday")){
            if (gender.equals("male") || gender.equals("Male")){
                System.out.println("Hello sir, enjoy your day");
            }
            if (gender.equals("female") || gender.equals("Female")) {
                System.out.println("Hello mam enjoy your day");
            }
        }
        if (day.equals("Friday") || day.equals("Saturday") || day.equals("Sunday")){
            if (gender.equals("male") || gender.equals("Male")){
                System.out.println("Hello sir enjoy your weekend");
            }
            if (gender.equals("female") || gender.equals("Female")) {
                System.out.println("Hello mam enjoy your weekend");
            }
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS