-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexporttest.java
More file actions
76 lines (62 loc) · 2.31 KB
/
exporttest.java
File metadata and controls
76 lines (62 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import edu.duke.*;
import org.apache.commons.csv.*;
/**
* Write a description of exporttest here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class exporttest {
public String countryInfo(CSVParser parser, String country){
for (CSVRecord record : parser){
String export = record.get("Country");
if(export.contains(country)){
System.out.print(record.get("Country" )+ ": ");
System.out.print(record.get("Exports") + ": ");
System.out.println(record.get("Value (dollars)"));}
}
return "NOT FOUND"; }
public void listExportersTwoProducts(CSVParser parser, String exportitem1, String exportitem2){
for(CSVRecord record : parser){
String export = record.get("Exports");
if( export.contains(exportitem1) && export.contains(exportitem2) ){
System.out.println(record.get("Country"));}
}
}
public int numberofExporters(CSVParser parser, String exportItem){
int count = 0;
for(CSVRecord record : parser){
String export = record.get("Exports");
if ( export.contains(exportItem)){
count = count + 1;}
}
return count ;}
public void bigExports(CSVParser parser, String amount){
for(CSVRecord record : parser){
String value = record.get("Value (dollars)");
if( value.length() > amount.length()){
System.out.print(record.get("Country") + " ");
System.out.println(record.get("Value (dollars)"));
}}}
public void tester(){
FileResource fr = new FileResource();
CSVParser parser = fr.getCSVParser();
countryInfo(parser,"Nauru");
//listExportersTwoProducts(parser,"gold","diamonds");
}
public void tester1(){
FileResource fr = new FileResource();
CSVParser parser = fr.getCSVParser();
listExportersTwoProducts(parser,"cotton","flowers");
}
public void tester2(){
FileResource fr = new FileResource();
CSVParser parser = fr.getCSVParser();
int number = numberofExporters(parser,"cocoa");
System.out.println(number);
}
public void tester3(){
FileResource fr = new FileResource();
CSVParser parser = fr.getCSVParser();
bigExports(parser,"$999,999,999,999");
}}