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..

Computer Science & Information Technology

You might also like to view...

Explain how vendors make a profit from open source software.

What will be an ideal response?

Computer Science & Information Technology

The memory device that provides a computer with very large, long-term storage area for storing programs and data even when the computer is off, is the ________

A) hard drive B) cache C) register D) RAM

Computer Science & Information Technology

A slicer allows you to filter data based on distinct values in PivotTable columns

Indicate whether the statement is true or false.

Computer Science & Information Technology

Once a project is underway, it is managed to completion using a process known as a negative ____________________ loop.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology