Question: JAVA Assignment 1.3: Social Security Numbers (10 pts) Write a program that reads in a series of numbers, as Strings, from a file and converts

JAVA

Assignment 1.3: Social Security Numbers (10 pts)

Write a program that reads in a series of numbers, as Strings, from a file and converts them to valid social security numbers.

The numbers are contained in file is called numbers.txt.

This program must use a loop to read in each number from the file and store it temporarily as a String variable

As it reads in each number, it should convert the number to a valid SSN in the format XXX-XX-XXXX by calling a method named formatSSN.

Here is the information about this method: The method is named formatSSN It take in a String array variable parameter It alters the array of Strings so that each String is a properly formatted social security number, in the format XXX-XX-XXXX This function must use the substring method to format the numbers It returns nothing

The program will use a loop to read in each number, and store them in an array of Strings

It should then call the formatSSN method on the String array.

Note: You may assume that the array is of length 10 when you declare it.

After each String is converted to a formatted social security number, write the array out to a file called socials.txt, using PrintWriter

Copy and paste the starter code below into a new file called SSN.java

import java.util.Scanner;

public class SSN {

/**

* converts an array of Strings to a formatted social security number

* @param numbers the array of Strings containing the unformatted digits

*/

//Write your method here

public static void main(String[] args) {

//write the program logic here

String number;

while (????) {

//fill in loop body here

}

}

}

Copy and paste the below data into a file called numbers.txt:

555666777

333444555

111888494

333222567

123444555

888999000

111666434

222456333

111222999

456889939

Below is the output that your program should give inside of the socials.txt file:

555-66-6777

333-44-4555

111-88-8494

333-22-2567

123-44-4555

888-99-9000

111-66-6434

222-45-6333

111-22-2999

456-88-9939

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!