java binary search from array list, lexicon words - java

My code reads a file called sort.txt, in which there are lexicon words ordered alphabetically and by length. There is one word in each line. The program works fine and please don't comment how it is written. The user then inputs a word he is searching for, e.g. "C**", and program returns all possible matches (Car, Cat, Cam, etc.). My question is how to search the array using binary search to speed things up. But the binary search would only be used if the first or first two or first 3 characters were input by the user, for instance "Ca*" or "Mou**". If the user inputs "***se" for instance, then the program would skip the binary search and would search the entire array.
package test;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.InputMismatchException;
import java.util.Scanner;
public class main{
public static void main(String[] args) {
String izbira;
int dolzina=0;
Scanner in = new Scanner(System.in);
String vnos;
Scanner input = new Scanner(System.in);
ArrayList list1 = new ArrayList();
ArrayList list2 = new ArrayList();
ArrayList list3 = new ArrayList();
ArrayList list4 = new ArrayList();
ArrayList list5 = new ArrayList();
ArrayList list6 = new ArrayList();
ArrayList list7 = new ArrayList();
ArrayList list8 = new ArrayList();
ArrayList list9 = new ArrayList();
ArrayList list10plus = new ArrayList();
try {
File file = new File("sort.txt");
FileReader fileReader = new FileReader(file);
BufferedReader bufferedReader = new BufferedReader(fileReader);
String vrstica;
while ((vrstica = bufferedReader.readLine()) != null) {
if (vrstica.length() == 1) {
list1.add(vrstica);
}
if (vrstica.length() == 2) {
list2.add(vrstica);
}
if (vrstica.length() == 3) {
list3.add(vrstica);
}
if (vrstica.length() == 4) {
list4.add(vrstica);
}
if (vrstica.length() == 5) {
list5.add(vrstica);
}
if (vrstica.length() == 6) {
list6.add(vrstica);
}
if (vrstica.length() == 7) {
list7.add(vrstica);
}
if (vrstica.length() == 8) {
list8.add(vrstica);
}
if (vrstica.length() == 9) {
list9.add(vrstica);
}
if (vrstica.length() > 9) {
list10plus.add(vrstica);
}
}
do{
do {
System.out.println("Vnesi dožino besede, ki jo iščeš:");
if (in.hasNextInt()) {
dolzina = in.nextInt();
} else if (in.hasNextLine()) {
System.out.printf("Napačen vnos! Poskusi ponovno:%n ",
in.nextLine());
}
} while (dolzina <= 0);
System.out.println("Vnesi besedo za neznano črko vpiši * :");
vnos = input.nextLine();
vnos = vnos.replace("*", ".");
if (dolzina == 1) {
for (int i = 0; i < list1.size(); i++) {
String s = (String) list1.get(i);
if (s.matches(vnos))
System.out.println(s);
}
}
if (dolzina == 2) {
for (int i = 0; i < list2.size(); i++) {
String s = (String) list2.get(i);
if (s.matches(vnos))
System.out.println(s);
}
}
if (dolzina == 3) {
for (int i = 0; i < list3.size(); i++) {
String s = (String) list3.get(i);
if (s.matches(vnos))
System.out.println(s);
}
}
if (dolzina == 4) {
for (int i = 0; i < list4.size(); i++) {
String s = (String) list4.get(i);
if (s.matches(vnos))
System.out.println(s);
}
}
if (dolzina == 5) {
for (int i = 0; i < list5.size(); i++) {
String s = (String) list5.get(i);
if (s.matches(vnos))
System.out.println(s);
}
}
if (dolzina == 6) {
for (int i = 0; i < list6.size(); i++) {
String s = (String) list6.get(i);
if (s.matches(vnos))
System.out.println(s);
}
}
if (dolzina == 7) {
for (int i = 0; i < list7.size(); i++) {
String s = (String) list7.get(i);
if (s.matches(vnos))
System.out.println(s);
}
}
if (dolzina == 8) {
for (int i = 0; i < list8.size(); i++) {
String s = (String) list8.get(i);
if (s.matches(vnos))
System.out.println(s);
}
}
if (dolzina == 9) {
for (int i = 0; i < list9.size(); i++) {
String s = (String) list9.get(i);
if (s.matches(vnos))
System.out.println(s);
}
}
if (dolzina > 9) {
for (int i = 0; i < list10plus.size(); i++) {
String s = (String) list10plus.get(i);
if (s.matches(vnos))
System.out.println(s);
}
}
dolzina=-1;
System.out.println("Ponovni vnos (da/ne):");
Scanner inn= new Scanner (System.in);
izbira = inn.next();
}while (izbira.equalsIgnoreCase("da"));
bufferedReader.close();
} catch (IOException e) {
e.printStackTrace();
}
}}

This won't give you a complete answer, but just puts in that direction.
You need to check if the first char is not *, then do a binary search otherwise iterate over all the strings and do String.endsWith().
if(vnos.charAt(0) != '*') {
//do binary search with the substring
} else {
//iterate and check if the string endsWith given suffix.
}

Related

Passing a parameter to another function

I wrote a code for hangman, and i want to pass the randomly guessed word(randomly guessed from a text file), to be passed to a function hangman() where i can get the length of the word. a random word will be guessed from the getRandomWord(String path) function and I have passed value obtained to function() But cannot seem to pass the and get the result.
public class Main {
public static void main(String[] args) throws IOException {
Main ma = new Main();
String stm= null;
loadWords();
//hangman(w);
function();
}
public static String[] loadWords() {
System.out.println("Loading words from file :");
try {
File myObj = new File("C:\\Users\\Admin\\Documents\\NetBeansProjects\\Main\\words.txt");
Scanner myReader = new Scanner(myObj);
while (myReader.hasNext()) {
String data = myReader.nextLine().toLowerCase();
String[] spl = data.split(" ");
System.out.println(spl.length + " words loaded");
return spl;
}
myReader.close();
} catch (FileNotFoundException e) {
System.out.println("An error occurred.");
e.printStackTrace();
}
return null;
// TODO: Fill in your code here
}
public static String getRandomWord(String path) throws IOException {
List<String> words = new ArrayList<String>();
try (BufferedReader reader = new BufferedReader(new FileReader(path))) {
String line;
while ((line = reader.readLine()) != null) {
String[] wordline = line.split("\\s+");
for (String word : wordline) {
words.add(word);
}
}
}
Random rand = new Random();
return words.get(rand.nextInt(words.size()));
}
public static List< String> getRemainingLetters(ArrayList< String> lettersGuessed) {
String alpha = "abcdefghijklmnopqrstuvwxyz";
String[] alpha1 = alpha.split("");
ArrayList< String> alpha2 = new ArrayList<>(Arrays.asList(alpha1));
for (int i = 0; i < lettersGuessed.size(); i++) {
for (int j = 0; j < alpha2.size(); j++) {
if (alpha2.get(j).equals(lettersGuessed.get(i))) {
alpha2.remove(j);
break;
}
}
}
return alpha2;
}
public static void function() throws IOException {
int numGuesses = 5;
String w = getRandomWord("C:\\Users\\Admin\\Documents\\NetBeansProjects\\Main\\words.txt");
String[] word = w.split("");
ArrayList< String> wList = new ArrayList<>(Arrays.asList(word));
ArrayList< String> wAnswer = new ArrayList< String>(wList.size());
for (int i = 0; i < wList.size(); i++) {
wAnswer.add("_ ");
}
int left = wList.size();
Scanner scanner = new Scanner(System.in);
boolean notDone = true;
ArrayList< String> lettersGuessed = new ArrayList< String>();
while (notDone) {
System.out.println();
String sOut = "";
List< String> lettersLeft = getRemainingLetters(lettersGuessed);
for (String s : lettersLeft) {
sOut += s + " ";
}
System.out.println("Letters Left: " + sOut);
sOut = "";
for (int i = 0; i < wList.size(); i++) {
sOut += wAnswer.get(i);
}
System.out.println(sOut + " Guesses left:" + numGuesses);
System.out.print("Enter a letter(* exit): ");
String sIn = scanner.next();
numGuesses--;
if (sIn.equals("*")) {
break;
}
lettersGuessed.add(sIn);
for (int i = 0; i < wList.size(); i++) {
if (sIn.equals(wList.get(i))) {
wAnswer.set(i, sIn);
left--;
}
}
if (left == 0) {
System.out.println("Congradulations you guessed it!");
break;
}
if (numGuesses == 0) {
StringBuilder sb = new StringBuilder();
for (String string : wList) {
sb.append(string);
}
String stm = sb.toString();
System.out.println("Sorry you ran out of guesses, the word was: " + stm);
break;
}
}
}
public static void hangman(String word) {
System.out.println("Welcome to Hangman Ultimate Edition");
System.out.println("I am thinking of a word that is " + word.length() + " letters long");
System.out.println("-------------");
}
}
Problems in your code:
Not passing the random word to the methods, hangman and function.
Instead of re-using the random word obtained from the method, getRandomWord in main, you have called getRandomWord again in the method, hangman which will give you a different random word causing incosistency.
Given below is the corrected program with a sample run:
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws IOException {
String word = getRandomWord("C:\\Users\\Admin\\Documents\\NetBeansProjects\\Main\\words.txt");
hangman(word);
function(word);
}
public static String getRandomWord(String path) throws IOException {
List<String> words = new ArrayList<String>();
try (BufferedReader reader = new BufferedReader(new FileReader(path))) {
String line;
while ((line = reader.readLine()) != null) {
String[] wordline = line.split("\\s+");
for (String word : wordline) {
words.add(word);
}
}
}
Random rand = new Random();
return words.get(rand.nextInt(words.size()));
}
public static List<String> getRemainingLetters(ArrayList<String> lettersGuessed) {
String alpha = "abcdefghijklmnopqrstuvwxyz";
String[] alpha1 = alpha.split("");
ArrayList<String> alpha2 = new ArrayList<>(Arrays.asList(alpha1));
for (int i = 0; i < lettersGuessed.size(); i++) {
for (int j = 0; j < alpha2.size(); j++) {
if (alpha2.get(j).equals(lettersGuessed.get(i))) {
alpha2.remove(j);
break;
}
}
}
return alpha2;
}
public static void function(String w) throws IOException {
// The available number of guesses = length of the random word
int numGuesses = w.length();
// Split the random word into letters
String[] word = w.split("");
ArrayList<String> wList = new ArrayList<>(Arrays.asList(word));
ArrayList<String> wAnswer = new ArrayList<String>(wList.size());
for (int i = 0; i < wList.size(); i++) {
wAnswer.add("_ ");
}
int left = wList.size();
Scanner scanner = new Scanner(System.in);
boolean notDone = true;
ArrayList<String> lettersGuessed = new ArrayList<String>();
while (notDone) {
System.out.println();
String sOut = "";
List<String> lettersLeft = getRemainingLetters(lettersGuessed);
for (String s : lettersLeft) {
sOut += s + " ";
}
System.out.println("Letters Left: " + sOut);
sOut = "";
for (int i = 0; i < wList.size(); i++) {
sOut += wAnswer.get(i);
}
System.out.println(sOut + " Guesses left:" + numGuesses);
System.out.print("Enter a letter(* exit): ");
String sIn = scanner.next();
numGuesses--;
if (sIn.equals("*")) {
break;
}
lettersGuessed.add(sIn);
for (int i = 0; i < wList.size(); i++) {
if (sIn.equals(wList.get(i))) {
wAnswer.set(i, sIn);
left--;
}
}
if (left == 0) {
System.out.println("Congradulations you guessed it!");
break;
}
if (numGuesses == 0) {
StringBuilder sb = new StringBuilder();
for (String string : wList) {
sb.append(string);
}
String stm = sb.toString();
System.out.println("Sorry you ran out of guesses, the word was: " + stm);
break;
}
}
}
public static void hangman(String word) {
System.out.println("Welcome to Hangman Ultimate Edition");
System.out.println("I am thinking of a word that is " + word.length() + " letters long");
System.out.println("-------------");
}
}
A sample run:
Welcome to Hangman Ultimate Edition
I am thinking of a word that is 3 letters long
-------------
Letters Left: a b c d e f g h i j k l m n o p q r s t u v w x y z
_ _ _ Guesses left:3
Enter a letter(* exit): c
Letters Left: a b d e f g h i j k l m n o p q r s t u v w x y z
_ _ _ Guesses left:2
Enter a letter(* exit): a
Letters Left: b d e f g h i j k l m n o p q r s t u v w x y z
_ _ _ Guesses left:1
Enter a letter(* exit): t
Sorry you ran out of guesses, the word was: fox
To make your existing code run, you should just clean up the main method:
remove unused code:
Main ma = new Main(); // no need to create an instance, you use only static methods
String stm= null; // not used anywhere
loadWords(); // not used, entire method may be removed:
// it reads words only in the first line
fix method function to have a String w parameter, move getting the random word out of this method.
Thus, resulting changes should be:
public static void main(String[] args) throws IOException {
String word = getRandomWord("C:\\Users\\Admin\\Documents\\NetBeansProjects\\Main\\words.txt");
hangman(word);
function(word);
}
public static void function(String w) throws IOException {
int numGuesses = 5;
String[] word = w.split("");
// ... the rest of this method remains as is
}

How to divide a sentence to words and compare with another string?

I have saved the units in .txt file. These I am getting in an array list. Now I want to check if any of the units present in the string.
List contains :
"units", "kg", "kilogms", "kilo", "literes",
"Liter", "packets", "packet", "gms", "grams", "half kg"
Like, if I have a string - 1kg rice, I want to get numbers from this string and I want to divide this sentence to words and want to compare with each item from array list of units. If it is present I want to save it. So I want to store 1kg and rice separately. string may contain any spaces I want to trim all those spaces and check compare.
Getting text file in an array list.
public class ReadTextFiles {
public static List<String> readItemNamesFile(Context context) {
String sText = null;
List<String> stringList;
try{
InputStream is = context.getResources().openRawResource(R.raw.item_names);
//Use one of the above as per your file existing folder
int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
sText = new String(buffer, "UTF-8");
String[] sTextArray = sText.replace("\"", "").split(",");
stringList = new ArrayList<String>(Arrays.asList(sTextArray));
System.out.print(stringList);
} catch (IOException ex) {
ex.printStackTrace();
return null;
}
return stringList;
}
}
public void getUnits()
{
List<String> units = new ArrayList<>();
units = ReadTextFiles.readUnitsFile(getActivity());
System.out.print(units.size());
}
Now I want to compare string suppose its "1 kg potato".Then should find potato from the array list. Also it should be case insensitive.
This is the full solution of your requirement as I understood:
String measuring = "\"units\", \"kg\", \"kilogms\", \"kilo\", \"literes\", \"Liter\", \"packets\", \"packet\", \"gms\", \"grams\", \"half kg\"";
String items = "\"Potato\", \"rice\", \"Eggs\", \"Maggi\", \"Dryfruits\", \"Maza\", \"cold drink\", \"sauce\", \"catchup\", \"coconut oil\"";
String matching = "Kg500 Potato";//"Potato 1 kg";
String item = "", measuringUnit = "", quantity = "";
private void findOut() {
String[] sMeasuringArray = measuring.replace("\"", "").split(", ");
ArrayList<String> measuringList = new ArrayList<String>(Arrays.asList(sMeasuringArray));
String[] sItemsArray = items.replace("\"", "").split(", ");
ArrayList<String> itemsList = new ArrayList<String>(Arrays.asList(sItemsArray));
String[] sMatchingArray = matching.split(" ");
matching = matching.toUpperCase();
for (int i = 0; i < measuringList.size(); i++) {
if (matching.contains(measuringList.get(i).toUpperCase())) {
measuringUnit = measuringList.get(i).trim();
break;
}
}
for (int i = 0; i < itemsList.size(); i++) {
if (matching.contains(itemsList.get(i).toUpperCase())) {
item = itemsList.get(i).trim();
break;
}
}
if (matching!= null) {
String[] part = matching.split("(?<=\\D)(?=\\d)|(?<=\\d)(?=\\D)");
for (int k = 0; k < part.length; k++) {
try {
Integer.parseInt(part[k]);
quantity = part[k];
break;
} catch (Exception ex) {
continue;
}
}
}
/*if (sMatchingArray != null) {
if (sMatchingArray.length == 3) {
for (int j = 0; j < sMatchingArray.length; j++) {
if (measuringUnit.trim().equals(sMatchingArray[j].trim())) {
quantity = sMatchingArray[j - 1].trim();
break;
}
}
} else if (sMatchingArray.length == 2) {
String[] part = matching.split("(?<=\\D)(?=\\d)|(?<=\\d)(?=\\D)");
for (int k = 0; k < part.length; k++) {
try {
Integer.parseInt(part[k]);
quantity = part[k];
break;
} catch (Exception ex) {
continue;
}
}
}
}*/
Log.e("Solution: ", "item = " + item + ", measuringUnit = " + measuringUnit + ", quantity = " + quantity);
}
I'm gonna be using algorithmic approach for the answer. So here it goes:
strItem = "1kg rice";
//Run a loop through the list of units and for each unit check this
if (strItem.contains(list.get(index)))
//Do the needful and break

HashMap key that is made up of multiple tokens and has non-null value mapping returns null

I am creating a currency exchange application from csv data and have hit a road block. I am storing the main currency exchange rate table in a LinkedHashMap of the following type:
LinkedHashMap[String,LinkedHashMap[String,Double]]
It will store the data as [Country, [Year,Rate]].
When I print to the console to confirm that the Map is being populated properly, I receive confirmation of a full KeySet and proper value mappings. Additionally, the application runs smoothly for any country names consisting of only one token. However, countries with more than one token in their names return null even though the map is populated with that key and its correct corresponding value.
For example, printing getExchangeRates() will return all K-V pairs including the following:
Australia={1960=0.8929, 1961=0.8929, 1962=0.8929, 1963=0.8929, 1964=0.8929, 1965=0.8929...},
Czech Republic={1990=21.145, 1991=27.92, 1992=28.37, 1993=29.153, 1994=28.785, 1995=26.541...},
New Zealand={1960=0.7143, 1961=0.7155, 1962=0.7192, 1963=0.7192, 1964=0.7192, 1965=0.7192...}
Printing getExchangeRates().get("Australia") will return the LinkedHashMap of years and rates; however, printing getExchangeRates().get("Czech Republic") or getExchangeRates().get("New Zealand") will return null.
Does anyone know why this would be happening? I am befuddled.
Code and csv snippet included for reference, but as I said, the HashMap appears to be populating correctly.
,1960,1961,1962,1963,1964,1965,1966,1967,1968,1969,1970,1971,1972,1973,1974,1975,1976,1977,1978,1979,1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008
Australia,0.8929,0.8929,0.8929,0.8929,0.8929,0.8929,0.8929,0.8929,0.8929,0.8929,0.8929,0.8827,0.8387,0.7041,0.6967,0.7639,0.8183,0.9018,0.8737,0.8946,0.8782,0.8702,0.9859,1.11,1.1395,1.4319,1.496,1.4282,1.2799,1.2646,1.2811,1.2838,1.3617,1.4706,1.3678,1.349,1.2779,1.3474,1.5918,1.55,1.7248,1.9334,1.8406,1.5419,1.3598,1.3095,1.328,1.1951,1.1922
Austria,1.88949,1.88949,1.88949,1.88949,1.88949,1.88949,1.88949,1.88949,1.88949,1.88949,1.88949,1.81394,1.67985,1.42293,1.35844,1.26573,1.30373,1.20106,1.05533,0.97145,0.94024,1.15745,1.23975,1.30544,1.45412,1.50356,1.1095,0.91877,0.89734,0.96151,0.82628,0.84852,0.79862,0.84534,0.83005,0.73265,0.76936,0.88691,0.89962,0.93863,1.0854,1.11751,1.06255,0.88603,0.80537,0.80412,0.79714,0.73064,0.68268
Belgium,1.23947,1.23947,1.23947,1.23947,1.23947,1.23947,1.23947,1.23947,1.23947,1.23947,1.23947,1.21145,1.09109,0.9662,0.96558,0.91173,0.957,0.88852,0.78067,0.72679,0.72488,0.92041,1.13264,1.26752,1.43243,1.47194,1.10739,0.92549,0.91146,0.9768,0.82841,0.84651,0.79697,0.85762,0.82936,0.73079,0.76752,0.88681,0.89982,0.93863,1.0854,1.11751,1.06255,0.88603,0.80537,0.80412,0.79714,0.73064,0.68268
Canada,0.9698,1.0131,1.0701,1.0811,1.0811,1.0811,1.0811,1.0811,1.0811,1.0811,1.0477,1.0098,0.9899,1.0001,0.978,1.0172,0.986,1.0635,1.1407,1.1714,1.1692,1.1989,1.2337,1.2324,1.2951,1.3655,1.3895,1.326,1.2307,1.184,1.1668,1.1457,1.2087,1.2901,1.3656,1.3724,1.3635,1.3846,1.4835,1.4857,1.4851,1.5488,1.5693,1.4011,1.301,1.2118,1.1344,1.0741,1.067
Czech Republic,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,21.145,27.92,28.37,29.153,28.785,26.541,27.145,31.698,32.281,34.569,38.598,38.035,32.739,28.209,25.7,23.957,22.596,20.294,17.072
Denmark,6.9071,6.9071,6.9071,6.9071,6.9071,6.9071,6.9071,6.9565,7.5,7.5,7.5,7.4169,6.9493,6.0495,6.0949,5.7462,6.045,6.0032,5.5146,5.261,5.6359,7.1234,8.3324,9.145,10.3566,10.5964,8.091,6.8403,6.7315,7.3102,6.1886,6.3965,6.0361,6.4839,6.3606,5.6024,5.7987,6.6045,6.7008,6.9762,8.0831,8.3228,7.8947,6.5877,5.9911,5.9969,5.9468,5.4437,5.0981
Finland,0.5382,0.5382,0.5382,0.5382,0.5382,0.5382,0.5382,0.58025,0.70638,0.70638,0.70638,0.70375,0.69736,0.64267,0.6347,0.61871,0.64995,0.6777,0.69249,0.65515,0.62735,0.72577,0.81074,0.93682,1.01081,1.04241,0.85263,0.73928,0.7035,0.72173,0.64307,0.68015,0.75339,0.96074,0.87853,0.73442,0.77258,0.87314,0.89881,0.93863,1.0854,1.11751,1.06255,0.88603,0.80537,0.80412,0.79714,0.73064,0.68268
France,0.75266,0.75266,0.75266,0.75266,0.75266,0.75266,0.75266,0.75266,0.75266,0.79185,0.84673,0.84496,0.769,0.67959,0.7339,0.65343,0.72855,0.74907,0.68802,0.64858,0.64419,0.8285,1.00191,1.16186,1.33227,1.36978,1.05588,0.91633,0.90812,0.97264,0.83013,0.86014,0.80704,0.86335,0.8464,0.76095,0.77986,0.8898,0.89938,0.93863,1.0854,1.11751,1.06255,0.88603,0.80537,0.80412,0.79714,0.73064,0.68268
Germany,2.14743,2.06221,2.04517,2.04517,2.04517,2.04517,2.04517,2.04517,2.04517,2.01619,1.87133,1.78481,1.63033,1.36648,1.3231,1.25793,1.28743,1.18731,1.027,0.93714,0.92936,1.15552,1.2407,1.30546,1.45511,1.50523,1.11026,0.91899,0.89795,0.96125,0.82611,0.84851,0.79846,0.84533,0.82972,0.73275,0.76938,0.88661,0.8997,0.93863,1.0854,1.11751,1.06255,0.88603,0.80537,0.80412,0.79714,0.73064,0.68268
Greece,0.08804,0.08804,0.08804,0.08804,0.08804,0.08804,0.08804,0.08804,0.08804,0.08804,0.08804,0.08804,0.08804,0.08694,0.08804,0.09406,0.10717,0.10811,0.10784,0.1087,0.12507,0.16261,0.19605,0.25844,0.33079,0.40534,0.4108,0.39745,0.41632,0.47665,0.46519,0.5349,0.55942,0.67278,0.71197,0.67986,0.70642,0.80134,0.86729,0.89698,1.07234,1.11751,1.06255,0.88603,0.80537,0.80412,0.79714,0.73064,0.68268
Hungary,..,..,..,..,..,..,..,..,60,60,60,59.82,55.26,48.97,46.75,43.97,41.58,40.96,37.91,35.58,32.53,34.31,36.63,42.67,48.04,50.12,45.83,46.97,50.41,59.07,63.21,74.74,78.99,91.93,105.16,125.68,152.65,186.79,214.4,237.15,282.18,286.49,257.89,224.31,202.75,199.58,210.39,183.63,172.11
Iceland,0.344,0.401,0.43,0.43,0.43,0.43,0.43,0.442,0.622,0.88,0.88,0.88,0.883,0.901,1,1.537,1.822,1.989,2.711,3.526,4.798,7.224,12.352,24.843,31.694,41.508,41.104,38.677,43.014,57.042,58.284,58.996,57.546,67.603,69.944,64.692,66.5,70.904,70.958,72.335,78.616,97.425,91.662,76.709,70.192,62.982,70.18,64.055,87.948
Ireland,0.45347,0.45347,0.45347,0.45347,0.45347,0.45347,0.45347,0.45977,0.52906,0.52906,0.52906,0.52176,0.50839,0.51827,0.54313,0.57397,0.70662,0.7279,0.66217,0.62038,0.61792,0.78889,0.89461,1.02173,1.1714,1.20068,0.94358,0.85443,0.83354,0.89585,0.76767,0.78888,0.74625,0.85993,0.84898,0.79198,0.79362,0.83757,0.8917,0.93863,1.0854,1.11751,1.06255,0.88603,0.80537,0.80412,0.79714,0.73064,0.68268
Italy,0.32226,0.32279,0.32279,0.32279,0.32279,0.32279,0.32279,0.32279,0.32279,0.32279,0.32279,0.32017,0.30121,0.30109,0.33587,0.33717,0.42987,0.45572,0.4383,0.4291,0.44232,0.58709,0.69851,0.78442,0.90739,0.98614,0.76994,0.66936,0.67223,0.70863,0.61877,0.64072,0.63649,0.81273,0.83276,0.84127,0.79687,0.87958,0.89668,0.93863,1.0854,1.11751,1.06255,0.88603,0.80537,0.80412,0.79714,0.73064,0.68268
Japan,360,360,360,360,360,360,360,360,360,360,360,349.33,303.17,271.7,292.08,296.79,296.55,268.51,210.44,219.14,226.74,220.54,249.08,237.51,237.52,238.54,168.52,144.64,128.15,137.96,144.79,134.71,126.65,111.2,102.21,94.06,108.78,120.99,130.91,113.91,107.77,121.53,125.39,115.93,108.19,110.22,116.3,117.75,103.36
Korea,..,..,..,..,..,..,271.3,270.5,276.7,288.2,310.6,347.2,392.9,398.3,404.5,484,484,484,484,484,607.4,681,731.1,775.8,806,870,881.5,822.6,731.5,671.5,707.8,733.4,780.7,802.7,803.4,771.3,804.5,951.3,1401.4,1188.8,1131,1291,1251.1,1191.6,1145.3,1024.1,954.8,929.3,1102.1
Luxembourg,1.23947,1.23947,1.23947,1.23947,1.23947,1.23947,1.23947,1.23947,1.23947,1.23947,1.23947,1.21145,1.09109,0.9662,0.96558,0.91173,0.957,0.88852,0.78067,0.72679,0.72488,0.92041,1.13264,1.26752,1.43243,1.47194,1.10739,0.92549,0.91146,0.9768,0.82841,0.84651,0.79697,0.85762,0.82936,0.73079,0.76752,0.88681,0.89982,0.93863,1.0854,1.11751,1.06255,0.88603,0.80537,0.80412,0.79714,0.73064,0.68268
Mexico,0.013,0.013,0.013,0.013,0.013,0.013,0.013,0.013,0.013,0.013,0.013,0.013,0.013,0.013,0.013,0.013,0.015,0.023,0.023,0.023,0.023,0.025,0.056,0.12,0.168,0.257,0.612,1.378,2.273,2.462,2.813,3.018,3.095,3.116,3.375,6.419,7.599,7.918,9.136,9.56,9.456,9.342,9.656,10.789,11.286,10.898,10.899,10.928,11.13
Netherlands,1.72436,1.6563,1.64268,1.64268,1.64268,1.64268,1.64268,1.64268,1.64268,1.64268,1.64268,1.58933,1.45641,1.26857,1.21993,1.14761,1.19977,1.11369,0.98179,0.91028,0.90217,1.13227,1.21169,1.29515,1.45604,1.50719,1.11177,0.91922,0.89693,0.96235,0.82631,0.84842,0.79796,0.84281,0.82588,0.72863,0.76503,0.88545,0.90018,0.93863,1.0854,1.11751,1.06255,0.88603,0.80537,0.80412,0.79714,0.73064,0.68268
New Zealand,0.7143,0.7155,0.7192,0.7192,0.7192,0.7192,0.7192,0.7337,0.8929,0.8929,0.8929,0.8806,0.8368,0.7368,0.7154,0.8323,1.0049,1.0303,0.9644,0.9785,1.0267,1.1528,1.3326,1.4968,1.764,2.0234,1.9132,1.6946,1.5264,1.6722,1.6762,1.7335,1.8618,1.8505,1.6865,1.5239,1.4549,1.5124,1.8683,1.8896,2.2012,2.3788,2.1622,1.7221,1.5087,1.4203,1.5421,1.3607,1.4227
Norway,7.1429,7.1429,7.1429,7.1429,7.1429,7.1429,7.1429,7.1429,7.1429,7.1429,7.1429,7.0418,6.5883,5.7658,5.5397,5.2269,5.4565,5.3235,5.2423,5.0641,4.9392,5.7395,6.454,7.2964,8.1615,8.5972,7.3947,6.7375,6.517,6.9045,6.2597,6.4829,6.2145,7.0941,7.0576,6.3352,6.4498,7.0734,7.5451,7.7992,8.8018,8.9917,7.9838,7.0802,6.7408,6.4425,6.4133,5.8617,5.64
Poland,..,..,..,..,..,..,0.0004,0.0004,0.0004,0.0004,0.0004,0.0004,0.0004,0.0003,0.0003,0.0003,0.0003,0.0003,..,0.004,0.0044,0.0051,0.0085,0.0092,0.0113,0.0147,0.0175,0.0265,0.0431,0.1439,0.95,1.0576,1.3626,1.8115,2.2723,2.425,2.6961,3.2793,3.4754,3.9671,4.3461,4.0939,4.08,3.8891,3.6576,3.2355,3.1032,2.768,2.4092
Portugal,0.1434,0.1434,0.1434,0.1434,0.1434,0.1434,0.1434,0.1434,0.1434,0.1434,0.1434,0.14122,0.13494,0.12228,0.12673,0.12746,0.15078,0.19092,0.21916,0.24403,0.24971,0.30699,0.39641,0.55257,0.73019,0.84993,0.74614,0.70272,0.71804,0.7854,0.71106,0.72067,0.67337,0.80207,0.82797,0.75371,0.76937,0.87445,0.89835,0.93863,1.0854,1.11751,1.06255,0.88603,0.80537,0.80412,0.79714,0.73064,0.68268
Slovak Republic,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,1.0214,1.0637,0.9863,1.0175,1.1159,1.1695,1.373,1.5281,1.6051,1.5046,1.2206,1.0707,1.0296,0.9858,0.8197,0.7091
Spain,0.36061,0.36061,0.36061,0.36061,0.36061,0.36061,0.36061,0.37063,0.42071,0.42071,0.42071,0.41752,0.38628,0.35015,0.3467,0.34502,0.4021,0.45654,0.46078,0.40343,0.43094,0.55487,0.66027,0.86203,0.96619,1.02199,0.84171,0.74212,0.7001,0.71147,0.61264,0.62452,0.61531,0.76485,0.8051,0.7494,0.76125,0.87997,0.89788,0.93863,1.0854,1.11751,1.06255,0.88603,0.80537,0.80412,0.79714,0.73064,0.68268
Sweden,5.1732,5.1732,5.1732,5.1732,5.1732,5.1732,5.1732,5.1732,5.1732,5.1732,5.1732,5.1168,4.7624,4.3673,4.4394,4.1522,4.3559,4.4816,4.5185,4.2871,4.2296,5.0634,6.2826,7.6671,8.2718,8.6039,7.1236,6.3404,6.1272,6.4469,5.9188,6.0475,5.8238,7.7834,7.716,7.1333,6.706,7.6349,7.9499,8.2624,9.1622,10.3291,9.7371,8.0863,7.3489,7.4731,7.3783,6.7588,6.5911
Switzerland,4.373,4.373,4.373,4.373,4.373,4.373,4.373,4.373,4.373,4.373,4.373,4.1342,3.8193,3.1648,2.9793,2.5813,2.4996,2.4035,1.788,1.6627,1.6757,1.9642,2.0303,2.0991,2.3497,2.4571,1.7989,1.4912,1.4633,1.6359,1.3892,1.434,1.4062,1.4776,1.3677,1.1825,1.236,1.4513,1.4498,1.5022,1.6888,1.6876,1.5586,1.3467,1.2435,1.2452,1.2538,1.2004,1.0831
Turkey,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,0.0001,0.0001,0.0002,0.0002,0.0004,0.0005,0.0007,0.0009,0.0014,0.0021,0.0026,0.0042,0.0069,0.011,0.0296,0.0458,0.0814,0.1519,0.2607,0.4188,0.6252,1.2256,1.5072,1.5009,1.4255,1.3436,1.4285,1.3029,1.3015
United Kingdom,0.35714,0.35714,0.35714,0.35714,0.35714,0.35714,0.35714,0.3621,0.41667,0.41667,0.41667,0.41092,0.40039,0.40817,0.42776,0.45204,0.55651,0.57327,0.52151,0.47218,0.4303,0.49764,0.57245,0.65973,0.75181,0.77925,0.6822,0.61193,0.56217,0.61117,0.56318,0.56702,0.56977,0.66676,0.65343,0.63367,0.64096,0.61084,0.60382,0.61806,0.66093,0.69466,0.66722,0.61247,0.54618,0.55,0.54349,0.49977,0.54397
United States,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
Euro area,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,0.76452,0.78756,0.8818,0.89199,0.93863,1.0854,1.11751,1.06255,0.88603,0.80537,0.80412,0.79714,0.73064,0.68268
Brazil,0.0001,0.0001,0.0001,0.0002,0.0005,0.0007,0.0009,0.001,0.0013,0.0016,0.0018,0.002,0.0023,0.0024,0.0026,0.0031,0.0041,0.0055,0.007,0.0104,0.0203,0.0359,0.0693,0.2227,0.7131,2.3925,5.2694,15.137,79.6677,-,-,0.0001,0.0016,0.0322,0.6393,0.9177,1.0051,1.078,1.1605,1.8139,1.8294,2.3496,2.9204,3.0775,2.9251,2.4344,2.1753,1.9471,1.8338
Chile,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,396.77,412.27,419.3,460.29,508.78,539.59,634.94,688.94,691.4,609.53,559.77,530.28,522.46,522.46
China,2.462,2.462,2.462,2.462,2.462,2.462,2.462,2.462,2.462,2.462,2.462,2.462,2.245,1.989,1.961,1.86,1.941,1.858,1.684,1.555,1.498,1.705,1.893,1.976,2.32,2.937,3.453,3.722,3.722,3.765,4.783,5.323,5.515,5.762,8.619,8.351,8.314,8.29,8.279,8.278,8.279,8.277,8.277,8.277,8.277,8.194,7.973,7.608,6.949
Estonia,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,13.223,12.991,11.465,12.038,13.882,14.075,14.678,16.969,17.478,16.612,13.856,12.596,12.584,12.466,11.434,10.694
India,4.77,4.78,4.77,4.78,4.79,4.79,6.3,7.56,7.58,7.59,7.57,7.52,7.59,7.74,8.1,8.38,8.96,8.74,8.19,8.13,7.86,8.66,9.46,10.1,11.36,12.37,12.61,12.96,13.92,16.23,17.5,22.74,25.92,30.49,31.37,32.43,35.43,36.31,41.26,43.06,44.94,47.19,48.61,46.58,45.32,44.1,45.31,41.35,43.51
Indonesia,..,..,..,..,..,..,..,150,296,326,363,392,415,415,415,415,415,415,442,623,627,632,661,909,1026,1111,1283,1644,1686,1770,1843,1950,2030,2087,2161,2249,2342,2909,10014,7855,8422,10261,9311,8577,8939,9705,9159,9141,9699
Israel 1,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,3.0113,3.1917,3.4494,3.8001,4.1397,4.0773,4.2057,4.7378,4.5541,4.482,4.4877,4.4558,4.1081,3.588
Russian Federation,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,0.992,2.191,4.559,5.121,5.785,9.705,24.62,28.129,29.169,31.349,30.692,28.814,28.284,27.191,25.581,24.853
Slovenia,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,..,0.11505,0.3392,0.47255,0.53751,0.49457,0.56486,0.66637,0.69326,0.75851,0.92913,1.01297,1.00254,0.86427,0.80279,0.80414,0.79715,0.73064,0.68268
South Africa,0.713,0.715,0.713,0.715,0.717,0.716,0.717,0.717,0.717,0.718,0.716,0.712,0.773,0.694,0.679,0.74,0.87,0.87,0.87,0.842,0.779,0.878,1.086,1.114,1.475,2.229,2.285,2.036,2.273,2.623,2.587,2.761,2.852,3.268,3.551,3.627,4.299,4.608,5.528,6.109,6.94,8.609,10.541,7.565,6.46,6.359,6.772,7.045,8.261
public static ArrayList<String> getYears() throws IOException {
File file = new File("exchangerates.csv");
BufferedReader br = new BufferedReader(new FileReader(file));
ArrayList<String> years = new ArrayList<String>();
String line = br.readLine();
String year = "";
for(int i = 1; i < line.length(); i++) {
if(line.charAt(i) != ',' && i != line.length()-1) {
year = year + line.charAt(i);
}
else if(i == line.length()-1) {
year = year + line.charAt(i);
years.add(year);
}
else {
years.add(year);
year = "";
}
}
br.close();
return years;
}
public static LinkedHashMap<String,LinkedHashMap<String,Double>> getExchangeRates() throws IOException {
File file = new File("exchangerates.csv");
BufferedReader br = new BufferedReader(new FileReader(file));
//burn first line
br.readLine();
LinkedHashMap<String,LinkedHashMap<String,Double>> exchangeRatesTable = new LinkedHashMap<String,LinkedHashMap<String,Double>>();
String line = null;
while((line = br.readLine()) != null) {
String country = "";
int index = 0;
while(line.charAt(index) != ',') {
country = country + line.charAt(index);
index++;
}
index++; //skip comma
LinkedHashMap<String,Double> yearlyRateMap = new LinkedHashMap<String,Double>();
for(String year : getYears()) {
String rateString = "";
for(int k = index; k < line.length(); k++) {
if(line.charAt(k) != ',' && k != line.length()-1) {
rateString = rateString + line.charAt(k);
index++;
}
else if(k == line.length()-1) {
rateString = rateString + line.charAt(k);
index++;
if(!rateString.equals("..")) {
Double exchangeRate = new Double(rateString);
yearlyRateMap.put(year, exchangeRate);
}
else {
index++;
break;
}
break;
}
else {
if(!rateString.equals("..") && !rateString.equals("-")) {
index++;
Double exchangeRate = new Double(rateString);
yearlyRateMap.put(year, exchangeRate);
}
else {
index++;
break;
}
break;
}
}
}
exchangeRatesTable.put(country, yearlyRateMap);
}
br.close();
return exchangeRatesTable;
}

Finding common characters java

I am having problem in my code and I cannot figure out why?
I am trying to compare strings to find common characters. I am missing the first character of first letter.
package findEquals;
import java.io.*;
class charequals {
public String name1, name2;
int l1, l2, m;
void getInputs() {
try {
BufferedReader br = new BufferedReader(new InputStreamReader(
System.in));
System.out
.println("Enter First Name(Enter \"1\" for \"AMITABH BACHCHAN\")\n");
name1 = br.readLine();
if (name1.equals("1"))
name1 = "AMITABH BACHCHAN";
System.out
.println("Enter Second Name(Enter \"1\" for \"RAJNIKANTH\")\n");
name2 = br.readLine();
if (name2.equals("1"))
name2 = "RAJNIKANTH";
} catch (IOException e) {
e.printStackTrace();
}
}
void findEquals() {
getInputs();
l1 = name1.length();
l2 = name2.length();
for (int i = 0; i < l1; i++) {
for (int j = 0; j < i; j++) {
if (name1.charAt(i) == name1.charAt(j)) {
m = 0;
break;
}
}
if (m == 0) {
m = 1;
continue;
}
for (int k = 0; k < l2; k++) {
if (name2.charAt(k) == name1.charAt(i)) {
System.out.println(name1.charAt(i) + " ");
break;
}
}
}
}
public static void main(String[] args) {
charequals a = new charequals();
a.findEquals();
}
}
OUTPUT(for default values): I T H N
It should be : A I T H N
Why am I missing the first letter?
This is what you need:
import java.io.*;
class charequals {
public String name1, name2;
int l1, l2, m;
void getInputs() {
try {
BufferedReader br = new BufferedReader(new InputStreamReader(
System.in));
System.out
.println("Enter First Name(Enter \"1\" for \"AMITABH BACHCHAN\")\n");
name1 = br.readLine();
if (name1.equals("1"))
name1 = "AMITABH BACHCHAN";
System.out
.println("Enter Second Name(Enter \"1\" for \"RAJNIKANTH\")\n");
name2 = br.readLine();
if (name2.equals("1"))
name2 = "RAJNIKANTH";
} catch (IOException e) {
e.printStackTrace();
}
}
void findEquals() {
getInputs();
l1 = name1.length();
l2 = name2.length();
for (int i = 0; i < l1; i++) {
for (int j = 0; j < l2; j++) {
if ( name1.charAt(i) == name2.charAt(j) ) {
System.out.print(name2.charAt(j) + " " );
char[] chars = name2.toCharArray();
chars[j] = '&';
name2 = new String(chars);
break;
}
}
}
}
public static void main(String[] args) {
charequals a = new charequals();
a.findEquals();
}
}
The changes are in findEquals(), i dind't understands very well your code but i guees this may help you to solve your problem. This work on ideone

Using scanner to read file and group data

I'm using scanner to read file and group data , ive done some work but facing problem when im tring to deal with
The data sets is this.
You can see a example here, that explain everything.
What i ve done is this :
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
public class TextScanner {
// static File f = new File("nrp1.txt");
public static void main(String[] args) throws FileNotFoundException {
TextScanner ts = new TextScanner();
ts.readfile();
}
public void readfile() throws FileNotFoundException {
FileInputStream fis = new FileInputStream("nrp1.txt");
Scanner scanner = new Scanner(fis);
int lineCount = 0;
String firstline = scanner.nextLine();
String secondline = scanner.nextLine();
String thirdline = scanner.nextLine();
String fourthline = scanner.nextLine();
String fifthline = scanner.nextLine();
String sixthline = scanner.nextLine();
String seventhline = scanner.nextLine();
String eighththline = scanner.nextLine();
List<Integer> intArrRIDA = new ArrayList<Integer>();
List<Integer> intArrRIDB = new ArrayList<Integer>();
int[] intRIDA = new int[Integer.parseInt(eighththline)];
int[] intRIDB = new int[Integer.parseInt(eighththline)];
List<Integer> intArrPOC = new ArrayList<Integer>();
List<Integer> intArrNORBC = new ArrayList<Integer>();
List<Integer> intArrRL = new ArrayList<Integer>();
String NoC="";
// COR arrays
thirdline.trim();
String[] CoR1 = thirdline.split(" ");
int[] intCoR1 = new int[CoR1.length];
for (int i = 0; i < intCoR1.length; i++) {
intCoR1[i] = Integer.parseInt(CoR1[i]);
}
fifthline.trim();
String[] CoR2 = fifthline.split(" ");
int[] intCoR2 = new int[CoR2.length];
for (int i = 0; i < intCoR2.length; i++) {
intCoR2[i] = Integer.parseInt(CoR2[i]);
}
seventhline.trim();
String[] CoR3 = seventhline.split(" ");
int[] intCoR3 = new int[CoR3.length];
for (int i = 0; i < intCoR3.length; i++) {
intCoR3[i] = Integer.parseInt(CoR3[i]);
}
while (scanner.hasNextLine()) {
lineCount++;
String line = scanner.nextLine().trim();
if (lineCount >= 1 && lineCount <= Integer.parseInt(eighththline)) {
// System.out.println("line: " + line);
String[] RID = line.split(" ");
for (int i = 0; i < 1; i++) {
intArrRIDA.add(Integer.parseInt(RID[0]));
intArrRIDB.add(Integer.parseInt(RID[1]));
// intRIDA[i] = Integer.parseInt(RID[0]);
// intRIDB[i] = Integer.parseInt(RID[1]);
// System.out.println("Id of RequirementA : " + intRIDA[i]);
// System.out.println("Id of RequirementB : " + intRIDB[i]);
}
}
if (lineCount == Integer.parseInt(eighththline)) {
NoC = scanner.nextLine();
}
//System.out.println("Number of Customer : " + NoC);
if (lineCount > Integer.parseInt(eighththline)) {
// System.out.println("line: " + line);
String[] Customers = line.split(" ");
System.out.println("Details of Customer : " +Arrays.toString(Customers) );
intArrPOC.add(Integer.parseInt(Customers[0]));
intArrNORBC.add(Integer.parseInt(Customers[1]));
for (int i = 0; i < 6; i++) {
intArrRL.add(Integer.parseInt(Customers[2]));
if (Customers[3] != null) {
intArrRL.add(Integer.parseInt(Customers[3]));
}
else if (Customers[4] != null) {
intArrRL.add(Integer.parseInt(Customers[4]));
}
else if (Customers[5] != null) {
intArrRL.add(Integer.parseInt(Customers[5]));
}
else if (Customers[6] != null) {
intArrRL.add(Integer.parseInt(Customers[6]));
}
else
continue;
}
}
}
System.out.println("Level of requirements, t: " + firstline);
System.out.println("Number of requirements in Level 1: " + secondline);
System.out.println("Costs of requirements in Level 1 : "
+ Arrays.toString(intCoR1));
System.out.println("Number of requirements in Level 2: " + fourthline);
System.out.println("Costs of requirements in Level 2 : "
+ Arrays.toString(intCoR2));
System.out.println("Number of requirements in Level 3: " + sixthline);
System.out.println("Costs of requirements in Level 3 : "
+ Arrays.toString(intCoR3));
System.out.println("Number of dependencies: " + eighththline);
// System.out.println("Id of RequirementA : " +
// Arrays.toString(intRIDA));
// System.out.println("Id of RequirementB : " +
// Arrays.toString(intRIDB));
System.out.println("Id of RequirementA : " + intArrRIDA);
System.out.println("Id of RequirementB : " + intArrRIDB);
System.out.println("Number of Customer : " + NoC);
System.out.println("Profit of Customer : " + intArrPOC);
System.out.println("Number of requests by Customer: " + intArrNORBC);
System.out.println("Requirements List : " + intArrRL);
}
private boolean isNumeric(String number) {
try {
Integer.parseInt(number);
return true;
} catch (NumberFormatException e) {
return false;
}
}
}
But as you can see :
for (int i = 0; i < 6; i++) {
intArrRL.add(Integer.parseInt(Customers[2]));
if (Customers[3] != null) {
intArrRL.add(Integer.parseInt(Customers[3]));
}
else if (Customers[4] != null) {
intArrRL.add(Integer.parseInt(Customers[4]));
}
else if (Customers[5] != null) {
intArrRL.add(Integer.parseInt(Customers[5]));
}
else if (Customers[6] != null) {
intArrRL.add(Integer.parseInt(Customers[6]));
}
else
continue;
}
This part is not correct ,and i need them to linked with Profit of Customer and Number of requests by Customer and when i implement further stuffs, i may able to find the corresponding Requirements List and the number of request by Profit of Customer...
I haven't started doing this method yet but that would be great if you can help me with this as well!
Thanks!

Categories

Resources