I think my code is good but I don't know what the format should has a solution to the task. I think it can be resolved in many ways.
package pl.codegym.task.task15.task1527;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
/*
Parser żądań
*/
public class Solution {
public static void main(String[] args) throws Exception {
ArrayList<String> sList = new ArrayList<>();
ArrayList<Double> dList = new ArrayList<>();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String tekst = reader.readLine();
// String tekst = "http://codegym.cc/alpha/index.html?obj=3.14&name=Amigo";
// String tekst = "http://codegym.cc/alpha/index.html?lvl=15&view&name=Amigo";
String sValue = "";
double dValue = 0;
String[] wynik = new String[2];
String[] rezultat = new String[2];
String[] r = new String[2];
wynik = tekst.split("\\?", 2);
rezultat = wynik[1].split("&", tekst.length());
// System.out.println(Arrays.asList(wynik));
// System.out.println(Arrays.asList(rezultat));
for (int i = 0; i < rezultat.length; i++) {
r = rezultat[i].split("=", 2);
sList.add(r[0]);
if (rezultat[i].contains(".")) {
sList.add(r[1]);
} else {
}
}
for (String s : sList) {
try {
double d = Double.parseDouble(s);
dList.add(d);
dValue += d;
} catch (Exception e) {
sValue += s + " ";
}
}
sValue = sValue.trim();
alert(sValue);
// if (dList.size() != 0)
alert(dValue);
}
public static void alert(double value) {
System.out.println("double: " + value);
}
public static void alert(String value) {
System.out.println(value);
}
}