Question: Java designing method Iwant to add in condition when the female user put a value in status is not equal in S, s ,M and
Java designing method
Iwant to add in condition when the female user put a value in status is not equal in S, s ,M and m the output will be Hellow Ma'am + name.
I want to add in condition if male user put a value in sex is not equal to sex which are M, m print Hellow + name
import java.util.Scanner; public class Main { public static void main(String[] args){ greet("Erish", 'f', 's'); } public static void greet(String name, char sex, char status){ if(sex == 'M'|| sex == 'm') { System.out.print("Hellow Mr."+ name+"!"); } else if(sex == 'F'|| sex == 'f' && (status == 'S' || status == 's')) { System.out.print("Hellow Ms."+ name+"!"); } else if(sex == 'F'|| sex == 'f' && status == 'M' || status == 'm') { System.out.print("Hellow Mrs."+ name+"!"); } } } Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
