I was given a text file that has list of names phone numbers, calls in and out ect... Like this
Adams#Marilyn#8233331109#0#0#01012014#C
Anderson#John#5025559980#20#15#12152013#M
Baker-Brown#Angelica#9021329944#0#3#02112014#C
The # are delimiters between data items and each line has the call status as the last item. I need to know how I can display each persons information on the screen in a format such as:
Name Phone Calls Out Calls In Last Call
Marilyn Adams (823) 333-1109 0 0 01-01-2104
John Anderson (502) 555-9980 20 15 12-15-2013
Angelica Baker-Brown (859) 254-1109 11 5 02-11-2014
I have to use substring method to extract the phone number and add parentheses/dashes ect I also must have a while statement and a delimiter...
So Far my code looks like this Also I am in a beginners Java coding class....
import java.util.Scanner; import java.io.*; public class phonedata2_1 { public static void main (String[] args) throws IOException { String Phonefile, FirstName, LastName; Scanner PhoneScan, fileScan; System.out.println (" Name Phone Calls Out Calls In Last Call Status"); fileScan = new Scanner(new File("phonedata.txt")); while (fileScan.hasNext()) { Phonefile = fileScan.nextLine(); PhoneScan = new Scanner(Phonefile); PhoneScan.useDelimiter("#"); System.out.println(PhoneScan.next()+" "+ PhoneScan.next()+"\t" + PhoneScan.next()+"\t" + PhoneScan.next()+"\t" + PhoneScan.next()+"\t" + PhoneScan.next()+"\t" + PhoneScan.next()); } System.out.println ("\nTotal outgoing calls for the period: " + "\nTotal incoming calls for the period: \n"); } }