In: Computer Science
Write a program in java which is in main and uses no classes, methods, loops or if statements Ask the user to enter their first name Ask the user to enter their last name Print their initials followed by periods (ie. Clark Kent = C. K.) Print the number of letters in their last name
Program Code Screenshot:
Sample output:
The screenshots are attached below for reference.
Please follow them for proper indentation and output.
Please see that no additional classes,loops and methods are used.
Program to copy:
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner inp=new Scanner(System.in);
String f,l;
System.out.println("Enter first
name:");
f=inp.next();//read first and last
names
System.out.println("Enter last
name:");
l=inp.next();
System.out.print(f.charAt(0)+"."+l.charAt(0)+".");//print first
letters with periods
System.out.println();
System.out.println("The number of
letters in last name:"+l.length());//print number of last name
characters
}
}