Three-letter acronyms are common in the business world. For example, in Java you
ID: 3603910 • Letter: T
Question
Three-letter acronyms are common in the business world. For example, in Java you use the IDE (Integrated Development Environment) in the JDK (Java Development Kit) to write programs used by the JVM (Java Virtual Machine) that you might send over a LAN (local area network). Programmers even use the acronym TLA to stand for three-letter acronym. Write a program that allows a user to enter three words, and display the appropriate three-letter acronym in all uppercase letters. If the user enters more than three words, ignore the extra words. Figure 1 below shows a typical execution. Save the file as ThreeLetterAcronym.java.
PLEASE READ BELOW, YOU NEED TWO .JAVA FILES, ONE WITH MAIN METHOD, ONE WITH CONSTRUCTOR.
Again, don’t forget to create the application/project ThreeLetterAcronymTest.java Class that has the main method and an object to use the ThreeLetterAcronym class.
Explanation / Answer
class ThreeLetterAcronymTest
{
public static void main()throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String s;
char x;
System.out.print("Enter any sentence: ");
s=br.readLine();
s=" "+s; //adding a space infront of the inputted sentence or a name
s=s.toUpperCase(); //converting the sentence into Upper Case (Capital Letters)
l=s.length(); //finding the length of the sentence
System.out.print("Output = ");
for(int i=0;i<3;i++)
{
x=s.charAt(i); //taking out one character at a time from the sentence
if(x==' ') //if the character is a space, printing the next Character along with a fullstop
System.out.print(s.charAt(i+1)+".");
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.