Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello guys, i have a problem to solve but i am facing some problems. I need to create a java OOP program where i use

Hello guys, i have a problem to solve but i am facing some problems. I need to create a java OOP program where i use generics, polymorphism and collections and i need to create an unitary test for the created program. I have already started but i dont know how to go further.. I would really appreciate if you guys could help me out

This program is something similar to a dynamic table that gives the same operations as SUM, COUNT, AVG, MIN and MAX

First we need to insert the name of the csv file that we want to open, then we need to choose the column name 1 and column name 2 separeted by a "," , then we need to insert the operations we want to do for example SUM and then we need to insert the column name that have the values we want to SUM, i will leave some input and output at the end of the question and will leave here the csv file and what i have got so far but you can feel free to edit the code:

public class Client { public static void main(String[] args) throws IOException { ArrayList> list = new ArrayList>(); BufferedReader reader = new BufferedReader(new FileReader(new File("src/Customer_Data.csv"))); String header = reader.readLine(); String[] keys = header.split(","); String line = null; while ((line = reader.readLine()) != null) { Map map = new HashMap(); String[] values = line.split(","); for (int i = 0; i map:list){ // for(String key:map.keySet()){ System.out.println(map.get("Gender")+" "+map.get("Geography")+" "+map.get("Tenure")); } } }

Generic ex:

Input:

F // File name

Column1,Column2 // Can be int or string

SUM //Operation

A // must be always int

Output: [{ [C1A, C2A]=NNN, [C1A, C2B]=NNN, [C1B, C2A]=NNN }]

Ex.1:

Input:

Customer_Data.csv

Geography,Gender

SUM

Tenure

Output: {[Germany, Male]=6646, [France, Male]=13901, [Spain, Male]=7020, [Spain, Female]=5445, [Germany, Female]=5924, [France, Female]=11192}

Ex. 2 Input:

Customer_Data.csv

Geography,Gender

AVG

Age

Output: {[Germany, Male]=39.42477203647417, [France, Male]=38.2964039229931, [Spain, Male]=38.64913544668588, [Spain, Female]=39.19926538108356, [Germany, Female]=40.154233025984915, [France, Female]=38.77399380804953}

Ex. 3:

Input:

Customer_Data.csv

Geography,Exited

SUM

CreditScore

Output: {[Germany, 1]=527219, [France, 1]=519951, [Germany, 0]=1107278, [France, 0]=2737486, [Spain, 0]=1345943, [Spain, 1]=267411}

The csv file has 10 000 lines soo i will leave here the dowload file : https://mega.nz/file/b0hDXQxY#Aggwpz7GVMY8-0Dl6N9L0tpEKekjmw9rmoCV_CdGTd8

I will leave here the first 23 lines of the file, thank you very much for those who can help me !

RowNumber,CustomerId,Surname,CreditScore,Geography,Gender,Age,Tenure,Balance,NumOfProducts,HasCrCard,IsActiveMember,EstimatedSalary,Exited
1,15634602,Hargrave,619,France,Female,42,2,0,1,1,1,101348.88,1
2,15647311,Hill,608,Spain,Female,41,1,83807.86,1,0,1,112542.58,0
3,15619304,Onio,502,France,Female,42,8,159660.8,3,1,0,113931.57,1
4,15701354,Boni,699,France,Female,39,1,0,2,0,0,93826.63,0
5,15737888,Mitchell,850,Spain,Female,43,2,125510.82,1,1,1,79084.1,0
6,15574012,Chu,645,Spain,Male,44,8,113755.78,2,1,0,149756.71,1
7,15592531,Bartlett,822,France,Male,50,7,0,2,1,1,10062.8,0
8,15656148,Obinna,376,Germany,Female,29,4,115046.74,4,1,0,119346.88,1
9,15792365,He,501,France,Male,44,4,142051.07,2,0,1,74940.5,0
10,15592389,H?,684,France,Male,27,2,134603.88,1,1,1,71725.73,0
11,15767821,Bearce,528,France,Male,31,6,102016.72,2,0,0,80181.12,0
12,15737173,Andrews,497,Spain,Male,24,3,0,2,1,0,76390.01,0
13,15632264,Kay,476,France,Female,34,10,0,2,1,0,26260.98,0
14,15691483,Chin,549,France,Female,25,5,0,2,0,0,190857.79,0
15,15600882,Scott,635,Spain,Female,35,7,0,2,1,1,65951.65,0
16,15643966,Goforth,616,Germany,Male,45,3,143129.41,2,0,1,64327.26,0
17,15737452,Romeo,653,Germany,Male,58,1,132602.88,1,1,0,5097.67,1
18,15788218,Henderson,549,Spain,Female,24,9,0,2,1,1,14406.41,0
19,15661507,Muldrow,587,Spain,Male,45,6,0,1,0,0,158684.81,0
20,15568982,Hao,726,France,Female,24,6,0,2,1,1,54724.03,0
21,15577657,McDonald,732,France,Male,41,8,0,2,1,1,170886.17,0
22,15597945,Dellucci,636,Spain,Female,32,8,0,2,1,0,138555.46,0

image text in transcribed

1 creuilscore Geography Gender Age Tenure Soma de Tenure 25093 11192 13901 12570 5924 6646 12465 5445 7020 50128 2 3 Rtulos de Li 4 France 5 Female 6 Male 7 Germany 8 Female 9 Male 10 Spain 11 Female 12 Male 13 Total Geral 14 15 Balance ? 16 17 Lin 18 : Geography i : Soma de Tenure i 19 20 : Gender 21

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

10th Edition

0137916787, 978-0137916788

Students also viewed these Databases questions

Question

Explain in detail how the Mughal Empire was established in India

Answered: 1 week ago

Question

Problem: Evaluate the integral: I - -[ze dx

Answered: 1 week ago

Question

Problem: Evaluate the integral: I = 1- 1 dx 9

Answered: 1 week ago