question archive Three-letter acronyms are common in the business world

Three-letter acronyms are common in the business world

Subject:Computer SciencePrice:2.87 Bought7

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. Save the file as ThreeLetterAcronym.java.

Purpose:
Create a java program from detailed directions.
Ability to:
Create appropriate variables for the data.
Follow established programming conventions for writing java programs
Able to correctly use arrays
Able to correctly use if statements
Able to input data from the user
Use the print statement for output

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE

Answer Preview

Answer:

import java.util.Scanner;

public class ThreeLetterAcronym {
   public static void main(String[] args) {
       // reading input from user
       Scanner input = new Scanner(System.in);
       String sentence = input.nextLine();
       // split sentence(with spaces) into words
       String[] words = sentence.split("\\s+");
       // Print 3 letter Upper case Acronym
       int i = 0;
       for (String curr : words) {
           if (i < 3) {
               System.out.print((curr.charAt(0) + "").toUpperCase());
               i++;
           }
       }
       input.close();
   }
}