Modify printFace() to have three parameters: char eyeChar, char noseChar, char m
ID: 3779812 • Letter: M
Question
Modify printFace() to have three parameters: char eyeChar, char noseChar, char mouthChar. Call the method with arguments 'o', '*', and '#', which should draw this face:
This is the given code to modify:
public class SimpleFace {
public static void printFace(char faceChar) {
System.out.println(" " + faceChar + " " + faceChar); // Eyes
System.out.println(" " + faceChar); // Nose
System.out.println(" " + faceChar + faceChar + faceChar); // Mouth
return;
}
public static void main (String [] args) {
printFace('o');
return;
}
}
Explanation / Answer
public class SimpleFace {
public static void printFace(char eyeChar,char noseChar,char mouthChar) {
System.out.println(" " + eyeChar + " " + eyeChar); // Eyes
System.out.println(" " + noseChar); // Nose
System.out.println(" " + mouthChar + mouthChar + mouthChar); // Mouth
return;
}
public static void main (String [] args) {
printFace('o','*','#');
return;
}
}
/*
sample output
o o
*
###
*/
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.