Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(Java 7 Programming Language) For this final project, you will be given a CDR (C

ID: 3574032 • Letter: #

Question

(Java 7 Programming Language)

For this final project, you will be given a CDR (Call Data Record) which is a log file from a phone system. There is a header that you must deal with at the top of the CDR which lets you know what information each column holds.

A call occurs when a LogID is created in the CDR (i.e. 10000); each time an event occurs during a call, the event number will change (i.e. 1, 2, …), but the LogID will stay the same. A new call occurs when the LogID changes (i.e. 10000 to 10001) which resets the event back to 1.

You can detect an on-hold record (row) using the Connection column. If the first character is a ‘H’, then the call is on-hold. (i.e. H113, H112) You would use the corresponding time information for the number of seconds the call was on-hold for the calculations. Hint: If you have an array of strings named cdr_conn, and the first element contains the word “Vegas”, you can access the first character of this first string element using cdr_conn[0].charAt(0); this would contain a ‘V’. (i.e. cdr_conn[0].charAt(1) contains a ‘e’, cdr_conn[0].charAt(2) contains a ‘g’)

This project has these requirements:

1. The data for this project is contained in the attached file “cdr_log_tab.txt”. Each of the columns are separated by tabs. You may only read the data in from the file once, and you must only store the data in arrays.

2. You must use parallel arrays and read each column into its corresponding array. (Extra Credit use an array of objects to store the data)

3. You must create a looping menu system resembling the following:Call Data Record Menu: When the number is selected, the following action occurs.

1. Displays average and longest on hold times.

2. Displays total number of calls, events, and average number of events per call.

3. Extra Credit: Allows user to enter a phone number and reports if that number is in the CDR

4. Quits the program

4. The program must be modular using at least 2 classes and must contain at least the following methods

: main test program – Runs the program

onHold – Calculates and prints the longest and average on-hold times

eventsPerCall – Calculates and prints the total number of calls, total numbers of events, and average number of events per call.

Extra Credit:

didNumberCall – Checks if a given phone number is in the CDR and prints out information (PhoneNumber, LogID, Event, Date, and Time) about all found calls. Note: there may be multiple calls from the same phone number.

compareStrings7 – Used to compare 7-digit phone numbers

You must turn in – everything inside one zip file and upload on blackboard: 1. All source files (.java). (80%) 2. Algorithm (Must be in-depth - Word or PDF file only) (10%) 3. You must follow the style sheet. (10%)

Data File (cdr_log_tab.txt) Column Description

Each column of the CDR contains specific information related to the current state of the call. The following is a list of the columns with a description:

1. Type - This column can contain the following characters:

I - Inbound call

T - Transfer state

O - Outbound call

B - Bridged call. For example, a call in on one line that is forwarded over another line. This can include calls forwarded to remote extensions.

X - Blocked call

A - Account number assigned to the call with the same log #.

2. LogID - This column indicates log number for the call. For the duration of the call, the log number remains the same. The event number will increment with each change of state. The first digit of the log number indicates on which unit the event originated.

3. Event - This column tracks various state changes of the call. For example, when an auto attendant answers, the counter might be 1. When the caller selects an extension, the counter increments to 2, etc.

4. Date - This column shows the date of the call (MM/DD/YYYY).

5. Time - This column contains the time that the call entered a specific state. The time is displayed in 24-hour format (HH:MM).

6. Duration - This column indicates the total time the call was in this state/event. The time is displayed in seconds format (SS.00).

7. Connection - This column indicates where the call was for each event. This includes auto attendants, voicemail, extension ringing or queuing.

Ex = Connected to extension x

A0x = Connected to auto attendant x (x = 01 to 20)

Rx = Ringing at extension x

RCO = Ringing at telephone line.

Qx = Queued at extension x

Hx = Call on hold at extension x (On Hold i.e. H113, H111, …)

Mx = Connected to voice mailbox x

Cxy = Forwarded out on unit x line y. (See “9. Extension” below for more details).

8. PhoneNumber - This column displays the phone number of the inbound or the outbound caller if available.

9. Extension - This column indicates on which unit and line the call came in or out. The format of this information is unit and line number. Lines 01–08 are telephone lines and 09–16 are VoIP lines.

Example:

101 — unit 1,line 1

203 — unit 2, line 3

110 — unit 1, VoIP 2

cdr_log_tab.txt (EXAMPLE OF FILE)

Explanation / Answer

CDRMain.java
=============

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Scanner;


public class CDRMain {
static int recCount=0;
static ArrayList<CDRData> cdrd;
public static void main(String[] args) {
loadFile();
while(true){
switch(displayMenu()){
case 1:onHold();break;
case 2:eventsPerCall();break;
case 3:scanCall();break;
case 4:return;
}
}
}
public static int displayMenu(){
Scanner scanner = new Scanner(System.in);
loadFile();
while(true){
System.out.println("CDR Logger:");
System.out.println("===========");
System.out.println("1. Display average and longest on hold times");
System.out.println("2. Displays total number of calls, events, and average number of events per call.");
System.out.println("3. Extra Credit: Allows user to enter a phone number and reports if that number is in the CDR");
System.out.println("4. Quit");
System.out.print ("Enter the valid choice : ");
int c = scanner.nextInt();
if (c>=1 && c<=4) return c;
scanner.nextLine();
System.out.print ("Invalid choice!");
}
}
public static void loadFile(){
cdrd= new ArrayList<CDRData>();
String line;
try (
FileReader fileReader = new FileReader(new File("cdr_log_tab.txt"));
BufferedReader br = new BufferedReader(fileReader);
) {
int r=0;
while ((line = br.readLine()) != null) {
if (r>0) { //Skip header
cdrd.add(new CDRData(line));
recCount++;
}
r++;
}
}
catch(Exception e){
System.out.println("Error occured!");
e.printStackTrace();
}
}
public static void onHold(){
CDRData t;
int totHoldCalls=0;
double totHoldDur=0;
double maxHoldDur=0;
Iterator<CDRData> itr=cdrd.iterator();//getting Iterator from arraylist to traverse elements
while(itr.hasNext()){
t=itr.next();
if (t.isOnHold()){// if call is onhold sum total duration and total number of calls.
if (t.callDur>=maxHoldDur) maxHoldDur=t.callDur;
totHoldDur+=t.callDur;
totHoldCalls++;
}
}
System.out.println("Max onhold Duration : "+maxHoldDur);
System.out.println("Average onhold Duration : "+(totHoldDur/totHoldCalls));
}
public static void eventsPerCall(){
CDRData t;
ArrayList<Integer> calls=new ArrayList<Integer>(); //Will hold distinct number calls;
  
Iterator<CDRData> itr=cdrd.iterator();//getting Iterator from arraylist to traverse elements
while(itr.hasNext()){
t=itr.next();
if(!(calls.contains(t.logID))) calls.add(t.logID);
}
System.out.println("Total Numbers of call : "+calls.size());
System.out.println("Total number of Events : "+recCount);
System.out.println("Average number of Events per call : "+recCount/calls.size());
}
public static void scanCall(){
CDRData t;
Scanner scanner = new Scanner(System.in);
String inPhone=scanner.nextLine();

Iterator<CDRData> itr=cdrd.iterator();//getting Iterator from arraylist to traverse elements
while(itr.hasNext()){
t=itr.next();
t.printPhoneDetails(inPhone);// if call matches then display details
}
}
}

CDRData.java
============
package CDR;

public class CDRData {
   public
       char callType;
       int logID;
       int event;
       String callDate;
       String callTime;
       double callDur;
       String callConnType;
       String callExten;
       String callNumber;
       int callUnit;
       int callLVN;
       char callLOrV;
   CDRData(String feedline){
       String data[]=feedline.split(" ");
       callType=data[0].charAt(0);
       logID=Integer.parseInt(data[1]);
       event=Integer.parseInt(data[2]);
       callDate=data[3];
       callTime=data[4];
       callDur=Double.parseDouble(data[5]);
       callConnType=data[6];
       callNumber=data[7];
       callExten=data[8];
       callUnit=Character.getNumericValue(callExten.charAt(0));
       callLVN=Integer.parseInt(callExten.substring(1));
       if (callLVN>=1 && callLVN<=8){
           callLOrV='L'; // Line type
       } else{
           callLOrV='V'; // VOIP type
           callLVN-=8; // subtract 8 to get VOIP line
       }
   }
   boolean isOnHold(){
       return callConnType.charAt(0)=='H';
   }
   boolean didNumberCall(String inPhoneNumber){
       return inPhoneNumber.equals(callNumber);
   }
   void printPhoneDetails(String inPhoneNumber){
       if (didNumberCall(inPhoneNumber))
           System.out.println("PhoneNumber, LogID, Event, Date, and Time = "+callNumber+", "+logID+", "+event+", "+callDate+", "+callTime);
   }
   void printPhoneDetails(){
       System.out.println("PhoneNumber, LogID, Event, Duration, Date, and Time = "+callNumber+", "+logID+", "+event+", "+callDur+", "+callDate+", "+callTime);
   }
}

=======================================================

Tab delimited file
cdr_log_data.txt
================
Type   LogID   Event   Date   Time   Duration   Connection   PhoneNumber   Extension
I   10000   1   4/21/2016   18:04   8.00   RCO   2331934   101
T   10000   2   4/21/2016   18:04   289.00   E113   2331934   101
I   10001   1   4/21/2016   18:09   12.00   RCO   3030808   102
T   10001   2   4/21/2016   18:09   138.00   E113   3030808   102
I   10002   1   4/21/2016   18:12   8.00   RCO   7155202   101
T   10002   2   4/21/2016   18:13   7.00   E113   7155202   101
T   10002   3   4/21/2016   18:13   106.00   H113   7155202   101
T   10002   4   4/21/2016   18:14   70.00   E113   7155202   101
T   10002   5   4/21/2016   18:16   49.00   H113   7155202   101
T   10002   6   4/21/2016   18:16   5.00   E113   7155202   101
T   10002   7   4/21/2016   18:16   2.00   H113   7155202   101
T   10002   8   4/21/2016   18:16   133.00   E113   7155202   101
I   10003   1   4/21/2016   18:16   6.00   RCO   6536156   102
T   10003   2   4/21/2016   18:16   5.00   E113   6536156   102
I   10004   1   4/21/2016   18:18   12.00   RCO   2141716   102
T   10004   2   4/21/2016   18:18   411.00   E112   2141716   102
I   10005   1   4/21/2016   18:34   5.00   RCO   7057554   101
T   10005   2   4/21/2016   18:34   132.00   E111   7057554   101
I   10006   1   4/21/2016   18:53   6.00   RCO   4194947   101
T   10006   2   4/21/2016   18:53   6.00   E112   4194947   101
T   10006   3   4/21/2016   18:54   277.00   H112   4194947   101
T   10006   4   4/21/2016   18:58   13.00   E113   4194947   101
I   10007   1   4/21/2016   18:54   6.00   RCO   7124033   102
T   10007   2   4/21/2016   18:55   6.00   E112   7124033   102
T   10007   3   4/21/2016   18:55   224.00   H112   7124033   102
T   10007   4   4/21/2016   18:58   92.00   E112   7124033   102
I   10008   1   4/21/2016   19:33   3.00   RCO   5056849   101
T   10008   2   4/21/2016   19:33   0.00   E112   5056849   101
I   10009   1   4/21/2016   19:33   4.00   RCO   5056849   101
T   10009   2   4/21/2016   19:33   111.00   E112   5056849   101
I   10010   1   4/21/2016   19:49   4.00   RCO   3549372   101
T   10010   2   4/21/2016   19:49   7.00   E112   3549372   101
T   10010   3   4/21/2016   19:49   35.00   H112   3549372   101
I   10011   1   4/21/2016   20:30   4.00   RCO   2341133   101
T   10011   2   4/21/2016   20:31   104.00   E113   2341133   101
I   10012   1   4/21/2016   20:34   3.00   RCO   5628058   101
T   10012   2   4/21/2016   20:34   21.00   E113   5628058   101
I   10013   1   4/21/2016   20:35   3.00   RCO   5628058   101
T   10013   2   4/21/2016   20:35   13.00   E111   5628058   101
I   10014   1   4/21/2016   20:42   2.00   RCO   5628058   101
T   10014   2   4/21/2016   20:42   124.00   E112   5628058   101
I   10015   1   4/21/2016   21:11   6.00   RCO   8241321   101
T   10015   2   4/21/2016   21:11   165.00   E112   8241321   101
I   10016   1   4/21/2016   21:35   6.00   RCO   7271179   101
T   10016   2   4/21/2016   21:35   198.00   E112   7271179   101
I   10017   1   4/22/2016   7:47   14.00   A002   3712342   101
T   10017   2   4/22/2016   7:48   20.00   M416   3712342   101
I   10018   1   4/22/2016   8:04   7.00   RCO   3362173   101
T   10018   2   4/22/2016   8:05   222.00   E112   3362173   101
I   10019   1   4/22/2016   8:10   7.00   RCO   3750970   101
T   10019   2   4/22/2016   8:10   35.00   E117   3750970   101
T   10019   3   4/22/2016   8:10   4.00   H117   3750970   101
T   10019   4   4/22/2016   8:10   158.00   E111   3750970   101
I   10020   1   4/22/2016   8:14   2.00   RCO   8838601   101
T   10020   2   4/22/2016   8:14   8.00   E117   8838601   101
T   10020   3   4/22/2016   8:14   19.00   H117   8838601   101
T   10020   4   4/22/2016   8:14   117.00   E117   8838601   101
I   10021   1   4/22/2016   8:22   5.00   RCO   3712342   101
T   10021   2   4/22/2016   8:23   55.00   E117   3712342   101
O   10022   1   4/22/2016   8:25   67.00   E117   4946702   104
O   10023   1   4/22/2016   8:28   79.00   E111   2306585   102
O   10024   1   4/22/2016   8:30   40.00   E111   8148764   103
O   10025   1   4/22/2016   8:31   67.00   E111   3301949   103
O   10026   1   4/22/2016   8:33   56.00   E111   8602073   102
O   10027   1   4/22/2016   8:35   69.00   E111   2123146   102
I   10028   1   4/22/2016   8:36   6.00   RCO   7880401   101
T   10028   2   4/22/2016   8:36   114.00   E117   7880401   101
T   10028   3   4/22/2016   8:38   79.00   H117   7880401   101
T   10028   4   4/22/2016   8:39   45.00   E117   7880401   101
O   10029   1   4/22/2016   8:36   83.00   E111   3553900   102
O   10030   1   4/22/2016   8:38   71.00   E111   2082227   102
O   10031   1   4/22/2016   8:41   37.00   E111   9225896   102
O   10032   1   4/22/2016   8:42   75.00   E111   5075278   102
O   10034   1   4/22/2016   8:44   80.00   E111   8954224   102
O   10035   1   4/22/2016   8:45   45.00   E111   4932341   102
O   10036   1   4/22/2016   8:47   43.00   E111   7731265   102
O   10037   1   4/22/2016   8:49   51.00   E111   8527403   102
I   10038   1   4/22/2016   8:49   5.00   RCO   6194392   101
T   10038   2   4/22/2016   8:49   76.00   E117   6194392   101
O   10039   1   4/22/2016   8:50   75.00   E111   6145036   102
O   10040   1   4/22/2016   8:52   72.00   E111   2450384   102
I   10041   1   4/22/2016   8:54   6.00   RCO   2082169   101
T   10041   2   4/22/2016   8:54   308.00   E117   2082169   101
T   10041   3   4/22/2016   8:59   184.00   H117   2082169   101
T   10041   4   4/22/2016   9:02   104.00   E117   2082169   101
O   10042   1   4/22/2016   8:54   46.00   E111   7126553   102
O   10043   1   4/22/2016   8:55   75.00   E111   9285085   102
O   10044   1   4/22/2016   8:59   71.00   E111   9389617   102
O   10045   1   4/22/2016   9:00   71.00   E111   5337213   102
O   10046   1   4/22/2016   9:01   52.00   E111   3712342   102
O   10047   1   4/22/2016   9:02   75.00   E111   7543005   102
O   10048   1   4/22/2016   9:04   49.00   E111   2433506   102
O   10049   1   4/22/2016   9:05   58.00   E111   2566127   102
O   10050   1   4/22/2016   9:06   39.00   E111   7200404   102
O   10051   1   4/22/2016   9:07   78.00   E111   6185853   102
O   10052   1   4/22/2016   9:08   63.00   E111   3838667   102
O   10053   1   4/22/2016   9:09   48.00   E111   7543005   102
O   10054   1   4/22/2016   9:10   42.00   E111   7222845   102
O   10055   1   4/22/2016   9:11   61.00   E111   4029161   102
I   10056   1   4/22/2016   9:13   14.00   RCO   3530261   101
T   10056   2   4/22/2016   9:13   13.00   E111   3530261   101
T   10056   3   4/22/2016   9:13   22.00   H111   3530261   101
T   10056   4   4/22/2016   9:14   2597.00   E114   3530261   101
O   10057   1   4/22/2016   9:14   82.00   E111   7254573   102
O   10059   1   4/22/2016   9:15   63.00   E111   3043187   102
O   10060   1   4/22/2016   9:16   35.00   E111   8821567   102
O   10061   1   4/22/2016   9:17   53.00   E111   5960602   102
O   10062   1   4/22/2016   9:18   72.00   E111   3043087   102
O   10063   1   4/22/2016   9:19   67.00   E111   2254982   102
O   10064   1   4/22/2016   9:20   53.00   E111   9863690   102
O   10065   1   4/22/2016   9:21   82.00   E111   6150184   102
I   10066   1   4/22/2016   9:24   7.00   RCO   7132127   102
T   10066   2   4/22/2016   9:25   45.00   E117   7132127   102
I   10067   1   4/22/2016   9:27   7.00   RCO   7132127   102
T   10067   2   4/22/2016   9:27   9.00   E117   7132127   102
T   10067   3   4/22/2016   9:28   119.00   H117   7132127   102
T   10067   4   4/22/2016   9:30   53.00   E112   7132127   102
T   10067   5   4/22/2016   9:30   198.00   H112   7132127   102
T   10067   6   4/22/2016   9:34   108.00   E112   7132127   102
I   10068   1   4/22/2016   9:29   6.00   RCO   2044932   103
T   10068   2   4/22/2016   9:29   9.00   E112   2044932   103
T   10068   3   4/22/2016   9:30   73.00   H112   2044932   103
T   10068   4   4/22/2016   9:31   123.00   E111   2044932   103
I   10069   1   4/22/2016   9:30   12.00   RCO   6061530   104
T   10069   2   4/22/2016   9:30   8.00   E112   6061530   104
T   10069   3   4/22/2016   9:31   146.00   H112   6061530   104
T   10069   4   4/22/2016   9:33   48.00   E111   6061530   104
I   10070   1   4/22/2016   9:38   8.00   RCO   8719193   102
T   10070   2   4/22/2016   9:38   8.00   E112   8719193   102
T   10070   3   4/22/2016   9:38   13.00   H112   8719193   102
T   10070   4   4/22/2016   9:38   98.00   E112   8719193   102
T   10070   5   4/22/2016   9:40   138.00   H112   8719193   102
T   10070   6   4/22/2016   9:42   96.00   E112   8719193   102
I   10071   1   4/22/2016   9:40   7.00   RCO   6479444   103
T   10071   2   4/22/2016   9:40   76.00   E117   6479444   103
O   10072   1   4/22/2016   9:45   43.00   E112   3549300   103
I   10073   1   4/22/2016   9:45   9.00   RCO   6864619   102
T   10073   2   4/22/2016   9:45   8.00   E113   6864619   102
T   10073   3   4/22/2016   9:45   4.00   H113   6864619   102
T   10073   4   4/22/2016   9:45   24.00   E111   6864619   102
T   10073   5   4/22/2016   9:46   153.00   H111   6864619   102
T   10073   6   4/22/2016   9:48   397.00   E111   6864619   102
O   10074   1   4/22/2016   9:46   70.00   E112   3549300   103
I   10075   1   4/22/2016   9:48   6.00   RCO   6158476   103
T   10075   2   4/22/2016   9:48   11.00   E111   6158476   103
T   10075   3   4/22/2016   9:48   171.00   H111   6158476   103
T   10075   4   4/22/2016   9:51   31.00   E112   6158476   103
I   10076   1   4/22/2016   9:55   4.00   RCO   6158476   102
T   10076   2   4/22/2016   9:56   8.00   E112   6158476   102
T   10076   3   4/22/2016   9:56   97.00   H112   6158476   102
T   10076   4   4/22/2016   9:57   2.00   E114   6158476   102
I   10077   1   4/22/2016   9:58   11.00   RCO   6158476   101
T   10077   2   4/22/2016   9:58   10.00   E112   6158476   101
T   10077   3   4/22/2016   9:58   45.00   H112   6158476   101
T   10077   4   4/22/2016   9:59   205.00   E111   6158476   101
T   10077   5   4/22/2016   10:02   53.00   H111   6158476   101
T   10077   6   4/22/2016   10:03   163.00   E111   6158476   101
I   10078   1   4/22/2016   10:02   18.00   RCO   6864619   102
T   10078   2   4/22/2016   10:02   18.00   E112   6864619   102
I   10079   1   4/22/2016   10:02   6.00   RCO   3530261   103
T   10079   2   4/22/2016   10:02   44.00   E114   3530261   103
I   10080   1   4/22/2016   10:14   2.00   RCO   3549372   101
T   10080   2   4/22/2016   10:14   18.00   E111   3549372   101

===================================

Output:
=======
CDR Logger:
===========
1. Display average and longest on hold times
2. Displays total number of calls, events, and average number of events per call.
3. Extra Credit: Allows user to enter a phone number and reports if that number is in the CDR
4. Quit
Enter the valid choice : 1
Max onhold Duration : 277.0
Average onhold Duration : 96.1304347826087
CDR Logger:
===========
1. Display average and longest on hold times
2. Displays total number of calls, events, and average number of events per call.
3. Extra Credit: Allows user to enter a phone number and reports if that number is in the CDR
4. Quit
Enter the valid choice : 2
Total Numbers of call : 79
Total number of Events         : 489
Average number of Events per call : 6
CDR Logger:
===========
1. Display average and longest on hold times
2. Displays total number of calls, events, and average number of events per call.
3. Extra Credit: Allows user to enter a phone number and reports if that number is in the CDR
4. Quit
Enter the valid choice : 3
4194947
PhoneNumber, LogID, Event, Date, and Time = 4194947, 10006, 1, 4/21/2016, 18:53
PhoneNumber, LogID, Event, Date, and Time = 4194947, 10006, 2, 4/21/2016, 18:53
PhoneNumber, LogID, Event, Date, and Time = 4194947, 10006, 3, 4/21/2016, 18:54
PhoneNumber, LogID, Event, Date, and Time = 4194947, 10006, 4, 4/21/2016, 18:58
CDR Logger:
===========
1. Display average and longest on hold times
2. Displays total number of calls, events, and average number of events per call.
3. Extra Credit: Allows user to enter a phone number and reports if that number is in the CDR
4. Quit
Enter the valid choice : 4