Three-letter acronyms are common in the business world. For example, in Java you
ID: 3558690 • Letter: T
Question
Three-letter acronyms are common in the business world.
For example, in Java you use the IDE (integrated development
environment) and the JDK (Java Development Kit) to write
programs used by the JFM (Java Virual Machine) that you
might send over the 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.
Example:
- user enters: random access memory
- program output:
Original phrase was: random access memory
Three letter acronym is: RAM
Explanation / Answer
Program Code:
import java.util.Scanner;
public class Acronyms
{
public static void main(String args[])
{
String[] fullName = new String[3];
Scanner sc=new Scanner(System.in);
System.out.println("Enter a three word phrase:");
for(int i=0;i<3;i++)
{
fullName[i]=sc.next();
}
System.out.println("The acronym for this is: ");
for(int i=0;i<3;i++)
{
String s=Character.toString(fullName[i].charAt(0));
String x=s.toUpperCase();
System.out.print(x);
}
}
}
Output:
Enter a three word phrase:
java
virtual
machine
The acronym for this is:
JVM
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.