Question: To write a program that performs data analysis from class objects PROJECT DESCRIPTION Bank is in desperate need of analytics from its clients for its

To write a program that performs data analysis from class objects

PROJECT DESCRIPTION

Bank is in desperate need of analytics from its clients for its loan application process. Currently, records show 600 clients exist and the bank is hoping to expand its clientele by offering premium loans to deserved grantees.

Perform the data analysis as follows for this lab.

Project Details

-Add to your existing project files from lab 2, a new class called Records. Have the class extend the BankRecords class to grab hold its instance methods plus the BankRecord object array.

-Use Comparator class(es) where necessary to sort your BankRecord objects by specific fields for quick processing and retrieval.

-Perform the following analysis requirements and output outcomes for the Records class

Display the following data analytic results to the console:

overall average income

max and min age per location

number of females with mortgages

number of males with both a car and 1 child per location

-Write all displayed data to a text file called bankrecords.txt relative to your project path as well. Append your name to the end of the file plus the date.

BankRecords.class

/*

02/09/2017

BankRecords.java

Lab 02

*/

/*

* This program will read a CSV file to capture the data and print it in a more readable fashion

*/

package lab02;

import java.io.BufferedReader;

import java.io.FileReader;

import java.io.IOException;

import java.util.ArrayList;

import java.util.Arrays;

import java.util.Iterator;

import java.util.List;

public class BankRecords implements Client {

//decleration of all variables holding data.... private to only allow class to access them

private String id;

private int age;

private String sex;

private String region;

private double income;

private String married;

private int children;

private String car;

private String save_acct;

private String current_act;

private String mortgage;

private String pep;

ArrayList list; // ArrayList Collection of type StringBuffer to store each record

// Setters and getters of above attributes

public String getId() { //Getter

return id;

}

public void setId(String id) { //Setter

this.id = id;

}

public String getSex() {

return sex;

}

public void setSex(String sex) {

this.sex = sex;

}

public String getRegion() {

return region;

}

public void setRegion(String region) {

this.region = region;

}

public int getAge() {

return age;

}

public void setAge(int age) {

this.age = age;

}

public double getIncome() {

return income;

}

public void setIncome(double income) {

this.income = income;

}

public int getChildren() {

return children;

}

public void setChildren(int children) {

this.children = children;

}

public String getMarried() {

return married;

}

public void setMarried(String married) {

this.married = married;

}

public String getCar() {

return car;

}

public void setCar(String car) {

this.car = car;

}

public String getSave_act() {

return save_acct;

}

public void setSave_act(String save_act) {

this.save_acct = save_act;

}

public String getCurrent_act() {

return current_act;

}

public void setCurrent_act(String current_act) {

this.current_act = current_act;

}

public String getMortgage() {

return mortgage;

}

public void setMortgage(String mortgage) {

this.mortgage = mortgage;

}

public String getPep() {

return pep;

}

public void setPep(String pep) {

this.pep = pep;

}

//read file for data

public void readData() {

try{

list = new ArrayList(); // Creating object for ArrayList

FileReader fr = new FileReader("/Users/shanshahzad/Desktop/Eclipse/lab02/src/bank-Detail.csv"); // REading File bank-Details from D:\ Drive

BufferedReader br = new BufferedReader(fr); // Passing FileReader into BufferedReader

String record;

while((record=br.readLine())!=null){ // Accessing each record

StringBuffer sb = new StringBuffer();

sb.append(record); // Appending to StringBuffer

list.add(sb); // Adding to ArrayList

}

} catch(Exception e){

e.printStackTrace(); // Catching Exception

}

}

//read ALL variables incase we need to print for REFRENCE

public void processData() {

Iterator itr = list.iterator(); // Processing ArrayList using Iterator

int i=0;

while(itr.hasNext()){ // Iterating each record from list

if(i==25){

break;

}

StringBuffer sb = itr.next();

String col[] = sb.toString().split(","); // Splitting each attribute with comma seperator

this.setId(col[0]); // Setting each value to Setters

this.setAge(Integer.parseInt(col[1]));

this.setSex(col[2]);

this.setRegion(col[3]);

this.setIncome(Double.parseDouble(col[4]));

this.setMarried(col[5]);

this.setChildren(Integer.parseInt(col[6]));

this.setCar(col[7]);

this.setSave_act(col[8]);

this.setCurrent_act(col[9]);

this.setMortgage(col[10]);

this.setPep(col[11]);

this.printer(); // Calling printer for every record

i++;

}

}

//prints required info into lines

public void printer() {

System.out.println("[ID=" + this.getId() + ", Age=" + this.getAge() + ", Sex="

+ this.getSex() + ", Region=" + this.getRegion() + ", Income=$" + this.getIncome() +

", Mortgage=" + this.getMortgage() + " --------------------------------------");

}

public static void main(String[] args) {

BankRecords banker = new BankRecords(); /ew object

banker.readData();

banker.processData();

}

}

Client.java

/*

02/09/2017

Client.java

Lab 02

*/

package lab02;

public interface Client {

public static void readData(){} //read file detail

public static void processData() {} //process file detail

public static void printData() {} //print file detail

}

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!