Three-letter acronyms are common in the business world. For example, in Java you
ID: 3927736 • 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 Acronym.java. Again, Don't forget to create the application/project AcronymTest.java Class that has the main method and an object to use the Acronym class.Explanation / Answer
Answer:
Java Program:
import java.util.*;
public class Acronym
{
public static void main(String args[])
{
Scanner s = new Scanner(System.in);
int target = 0;
System.out.println("please enter three words:");
String input = s.nextLine();
String change = input.toUpperCase();
System.out.print ("Original phrase was "+input+" Three letter acronym is
"+change.charAt(0));
for(int i = 0; i<input.length()-1;i++)
{
if(input.charAt(i) == 32 && target < 2)
{
System.out.print(change.charAt(i+1));
target++;
}
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.