In Exercise 8, you created an application that modeled a telephone keypad. We would like to improve the operation of the application. Here is a list of the improvements to be made:
• The first number in the number cannot be 0. If the user types 0 as the first number, do nothing with it.
• Format the number using dashes, as follows:
• 1-000-000-0000 if the first digit entered is a 1.
• (000) 000-0000 if ten digits are entered.
• 000-0000 if seven digits are entered.
• Do not accept extra digits.
This application is pretty simple for the most part. A number of buttons must be created and multi-way switch used to detect which button on the keypad was pressed. But if we set an integer value, the rest of the code is simple. Create a method that checks to see if the digit entered is valid. Create methods that format the number in the different ways.
See the code in TelephoneKeypad.java..
You might also like to view...
When merging and comparing presentations, when does the Revisions pane open?
A) As soon as you click the Review tab B) After you click Merge on the Review tab C) After you click Compare on the Review tab D) Immediately after you open the original presentation
In C++, pass by reference for an integer parameter can be achieved …
A. by placing an & in front of the value when invoking the function. B. by placing an & following the data type of a parameter in the function prototype and the function header. C. by placing an & before the data type of a parameter in the function prototype and the function header. D. by doing nothing special, since pass by reference is the default way to pass integers.