Question
Numbers displayed on the screen must be formatted for readabiity. Think of your phone number, or Social Security number and Credit Card. Write a JAVA
Numbers displayed on the screen must be formatted for readabiity. Think of your phone number, or Social Security number and Credit Card. Write a JAVA program that uses a Scanner to take a single user input.
If the user enters 9 characters format it as a Social Security Number. It should appears as 123-45-6789 (must have dashes) If the user enters 10 characters format it as a phone number. It should appears as (123)456-7890 (parentheses around area code and a dash. If the user enters 16 characters format it as a credit card number. It should appears as 1234 5678 9012 3456 (use spaces every 4 digits)
The user must enter input all numbers and the input must have a length of 9, 10 or 16. If not display an appropriate error message.
- User enters a single input
- Output is formatted exactly as specified
- Solutions use printf()
- Solution handles errors appropriately
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started