1 If a users input string matches a known text message abbre

(1) If a user\'s input string matches a known text message abbreviation, output the unabbreviated form, else output: Unknown. Support two abbreviations: LOL -- laughing out loud, and IDK -- I don\'t know.

Sample input/output (as it would look in cloud9):


(2) Expand to also support these abbreviations:

BFF -- best friends forever

IMHO -- in my humble opinion

TMI -- too much information

Solution

Abbreviation.java

import java.util.Scanner;


public class Abbreviation {

   public static void main(String[] args) {
       Scanner scan = new Scanner(System.in);
       String shourCut[] = {\"LOL\",\"IDK\",\"BFF\",\"IMHO\",\"TMI\"};
       String abbreviation[] = {\"laughing out loud\",\"I don\'t know\",\"best friends forever\",\"in my humble opinion\",\"too much information\"};
       System.out.println(\"Input an abbreviation: \");
       String input = scan.next();
       boolean found = false;
       for(int i=0; i<shourCut.length; i++){
           if(shourCut[i].equalsIgnoreCase(input)){
               System.out.println(abbreviation[i]);
               found = true;
               break;
           }
       }
       if(!found){
           System.out.println(\"Unknown\");
       }
   }

}

Output:

Input an abbreviation:
BFF
best friends forever

Input an abbreviation:
LOL
laughing out loud

Input an abbreviation:
TPTY
Unknown

(1) If a user\'s input string matches a known text message abbreviation, output the unabbreviated form, else output: Unknown. Support two abbreviations: LOL --

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site