Answer:
// Method name is printDay .
// It receives a parameter of type int, called n
// Since the method does not return a value, the return type is set as 'void' .
public void printDay(int n){ //Begin of method header
// Write a nested if...else statement to
// check what the value of n is .
// Ff n is 1, print Monday
if(n == 1){
System.out.println("Monday");
}
//or if n is 2, print Tuesday
else if(n == 2){
System.out.println("Tuesday");
}
//or if n is 3, print Wednesday
else if(n == 3){
System.out.println("Wednesday");
}
//or if n is 4, print Thursday
else if(n == 4){
System.out.println("Thursday");
}
//or if n is 5, print Friday
else if(n == 5){
System.out.println("Friday");
}
//or if n is 6, print Saturday
else if(n == 6){
System.out.println("Saturday");
}
//or if n is 7, print Sunday
else if(n == 7){
System.out.println("Sunday");
}
//else, the user must have entered a value that is not within range.
//print 'invalid value' in the case.
else {
System.out.println("Invalid value");
}
} //Close of method header
Explanation:
The above code has been written using Java's syntax. Please go through the comments in the code for the explanation of every segment of the code.
Hope this helps!