Respuesta :
Answer:
first = input( "What is your first name? " )
last = input( "What is your last name? " )
def initials():
print ("Your initials are: "+first[0]+"."+last[0]+".")
initials ()
Explanation:
it works when I test but it won't submit. Hope this helps
Following are the program to prints the initials of the input value.
Program Explanation:
- Defining a class Main.
- Inside the class, a method "initials" is declared that takes two string variables "first, last" in the parameter.
- Inside the method, a return keyword is defined that uses the charAt method that returns the first character value of the parameters.
- In the next step, the main method is defined.
- Inside the main method, a print method is declared that calls initials method that accepts value in the parameter and prints its value.
Program:
public class Main //defining a class Main
{
static String initials(String first, String last)//defining a String method initials that input two variables in the parameter
{
return first.charAt(0)+"."+last.charAt(0)+".";//using charAt method that returns first character value
}
public static void main(String[] as) //defining main method
{
System.out.println(initials("Tracy", "Turtle"));//using print method that calls initials method that accepts value in parameter
System.out.println(initials("Peter", "Parker"));//using print method that calls initials method that accepts value in parameter
}
}
Output:
Please find the attached file.
Learn more:
brainly.com/question/2810164
