Please find the correct output for the below problem. The solution code is implemented as per the…

Please find the correct output for the below problem. The solution code is implemented as per the…
Please find the correct output for the below problem. The solution code is implemented as per the question. But half of the output coming correctly. please read the question. Problem statement: to get the user name whose submission_count is greater than threshold value based on the given page number. if page number is 1 , then i should print all the username whose submission_count is greater than threshold. if page number is 2, then i should print all the username whose submission_count is greater than threshold. But in my output i have printed username for page number=1 its not print the usernames for page number 2. please correct my solution code. import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.List; import com.google.gson.*; class Result { /*
* Complete the 'getUsernames' function below.
*
* The function is expected to return a STRING_ARRAY.
* The function accepts INTEGER threshold as parameter.
*
* URL for cut and paste
* https://jsonmock.hackerrank.com/api/article_users?page=
*/ public static List getUsernames(int threshold) {
String response;
int startPage = 1;
int totalPages = 1;
List titles = new ArrayList<>();
while (startPage <= totalpages)="">
try {
URL obj = new URL(“https://jsonmock.hackerrank.com/api/article_users/search/?page=”);

HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod(“GET”);
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
while ((response = in.readLine()) != null) {
JsonObject convertedObject = new Gson().fromJson(response, JsonObject.class);
totalPages = convertedObject.get(“total_pages”).getAsInt();
JsonArray data = convertedObject.getAsJsonArray(“data”);
for (int i = 0; i < data.size();="" i++)="">

int subcount=data.get(i).getAsJsonObject().get(“submission_count”).getAsInt();

String title = data.get(i).getAsJsonObject().get(“username”).getAsString();
if(subcount > threshold)
{

titles.add(title);
startPage+=1;
}
}
}

in.close();
//startPage+=1;

} catch (Exception ex) {
ex.printStackTrace();
} }
return titles;
}
} public class Solution {
public static void main(String[] args) throws IOException {
////BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(“C:\Users\sugus\OneDrive\Desktop\1.txt”)); int threshold = 500; List result = Result.getUsernames(threshold);
for(String a:result)
System.out.println(a); // bufferedWriter.write(result.stream().collect(joining(“n”))
// + “n”
// ); //bufferedReader.close();
// bufferedWriter.close();
}
}   May 13 2022 07:28 PM

Place your order
(550 words)

Approximate price: $22

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more
Open chat
1
You can contact our live agent via WhatsApp! Via + 1 (409) 205-8984

Feel free to ask questions, clarifications, or discounts available when placing an order.

Order your essay today and save 30% with the discount code DISCOUNT