Please fix this code. 4.6.1: Overload salutation printing. Complete the second printSalutation() method to print the following given personName "Holly" and customSalutation "Welcome": Welcome, Holly End with a newline. import java.util.Scanner; public class MultipleSalutations { public static void printSalutation(String personName) { System.out.println("Hello, " + personName); } //Define void printSalutation(String personName, String customSalutation)... public static void main (String personName, String customSalutation) { System.out.println("Welcome," + personName); printCustomSalutation("Welcome," + "Holly"); } public static void main (String [] args) { printSalutation("Holly", "Welcome"); printSalutation("Sanjiv"); } }
Welcome, Holly End with a newline.
import java.util.Scanner;
public class MultipleSalutations {
public static void printSalutation(String personName) {
System.out.println("Hello, " + personName);
}
//Define void printSalutation(String personName, String customSalutation)...
public static void main (String personName, String customSalutation) {
System.out.println("Welcome," + personName);
printCustomSalutation("Welcome," + "Holly");
}
public static void main (String [] args) {
printSalutation("Holly", "Welcome");
printSalutation("Sanjiv");
}
}
MultipleSalutations.java:12: error: cannot find symbol printCustomSalutation("Welcome," + "Holly"); ^ symbol: method printCustomSalutation(String) location: class MultipleSalutations MultipleSalutations.java:15: error: method printSalutation in class MultipleSalutations cannot be applied to given types; printSalutation("Holly", "Welcome"); ^ required: String found: String,String reason: actual and formal argument lists differ in length 2 errors
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images