This task is really confusing. The example output does not match the output they say you must have using the alert methods..
Anyway, my code does not verify when I match their output, or when I correctly us the alert methods.
Has anyone had the same issue?
package com.codegym.task.task15.task1527;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
/*
Request parser
*/
public class Solution {
public static void main(String[] args) throws IOException{
//write your code here
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String input = reader.readLine();
String[] myStrArray = input.split("[?]")[1].split("&");
ArrayList<String> list = new ArrayList<>();
for(String s : myStrArray) {
if(s.contains("=")) {
String[] temp = s.split("=");
for(int i = 0; i < temp.length; i++) {
list.add(temp[i].trim());
}
} else {
list.add(s.trim());
}
}
for(String s : list) {
try {
double d = Double.parseDouble(s);
alert(d);
} catch (NumberFormatException e) {
alert(s);
}
}
}
public static void alert(double value) {
System.out.println("double: " + value);
}
public static void alert(String value) {
System.out.println("String: " + value);
}
}