一份英国电子商务本科生的习题,大家来帮帮忙,说说算法就可以:)
You are required to design and implement (in Java) the front end of a web-based SMS (Short Message Service) gateway that will allow Internet users to send text messages to mobile phones.
SMS messages can be comprised of words or numbers (alpha-numeric characters) up to 160 characters in length. This limitation on message length, combined with the inconvenience of using mobile phone keypads for typing text has helped give rise to a popular culture of SMS abbreviations, similar to that found in internet chat-rooms. “b4n”, “L8”, “b4” and “btw” are examples of such usage (“bye for now”, “late”, “before” and “by the way”).
Your task at this stage is to design and write a Java program that will :
1) Prompt the user for a mobile phone number.
2) Verify the number is in a valid format (ie exactly 11 numeric characters etc).
3) Prompt the user for a text message.
4) Where possible, encode the message using SMS abbreviations.
5) Display the encoded (abbreviated) message to the user.
6) If text size still exceeds 160 characters, prompt user to edit the message.
7) Display the percentage reduction produced by this coding.
Bonus task:
O Implement a decoding algorithm that would recover the original text message from an abbreviated version.