Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Background Who's in Space The following URL provides information about all the people who are currently in space. http://api.open-notify.org/astros.json Paste the URL into a
Background Who's in Space The following URL provides information about all the people who are currently in space. http://api.open-notify.org/astros.json Paste the URL into a web browser and examine the JSON data that is returned. Assignment Download the Lab 7 starter project, unzip it with 7-zip and "Extract Here", and import it into Eclipse. You are going to write a program that accesses the above URL's to display the number of people currently in space as well as a detailed list of who is in space and where they are (usually the International Space Station). Write the program in three steps: 1. Write Java code to read input from the supplied URL into a single String. Output the String to verify the program works correctly. 2. Use the supplied org.json library (already included in the starter project) to parse the JSON and determine a count of the number of people in space. Output that value (with appropriate text labeling). 3. Use the supplied org.json library to parse the list of people in space and their location. Output that information. Example Output Note: output may differ from the results below as the list of people in space changes over time. {"message": "success", "number": 10, "people": [{"craft": "ISS", "name": "Sergey Ryzhikov"}, {"craft": "ISS", "name": "Kate Rubins"}, {"craft": "ISS", "name": "Sergey Kud-Sverchkov"}, {"craft": "ISS", "name": "Mike Hopkins"}, {"craft": "ISS", "name": "Victor Glover"}, {"craft": "ISS", "name": "Shannon Walker"}, {"craft": "ISS", "name": "Soichi Noguchi"}, {"craft": "ISS", "name": "Mark Vande Hei"}, {"craft": "ISS", "name": "Oleg Novitskiy"}, {"craft": "ISS", "name": "Pyotr Dubrov"}]} There are 10 people in space Sergey Ryzhikov is onboard: ISS Kate Rubins is onboard: ISS Sergey Kud-Sverchkov is onboard: ISS Mike Hopkins is onboard: ISS Victor Glover is onboard: ISS Shannon Walker is onboard: ISS Soichi Noguchi is onboard: ISS Mark Vande Hei is onboard: ISS Oleg Novitskiy is onboard: ISS Pyotr Dubrov is onboard: ISS Package Explorer X Project Explorer Lab7 src W #edu.cscc V V Main.java Main main(String[]): void module-info.java AstrosSolution > Referenced Libraries > JRE System Library [jdk-11.0.9.11-hotspot] lib json-20210307.jar *module-info.java X 1 module AstrosSolution { requires org.json; 123 3} Problems X @Javadoc Declaration Coverage 12 errors, 9 warnings, 0 others Description *Main.java X 2-import java.io. BufferedReader; 3 import java.io.IOException; 4 import java.io.InputStreamReader; 5 import java.net.MalformedURLException; 6 import java.net. URL; 7 import java.net. URL Connection; 8 import java.util.ArrayList; 9 import org.json. *; 10- /** 11 12 13 */ * Find out who's in space JSON library from: * https://github.com/stleary/JSON-java 14 public class Main { 15 public static void main(String[] args) { 16 final String theURLString = "http://api.open-notify.org/astros.json"; 17 Step 1 - read input from above URL and store in a String. Output the String to the console 18 // TODO - 19 // TODO - 20 // TODO - Step 2 - Using the org.json library, 21 // parse the JSON string to determine the number of people in orbit 22 // and then output that value 23 // TODO - Step 3 Parse the JSON object and print the list of people 24 // in orbit and where they are. 25 } 26 Resource - Path Location Type
Step by Step Solution
★★★★★
3.35 Rating (161 Votes )
There are 3 Steps involved in it
Step: 1
Step 1 Read input from the URL and store it in a String Output the String to the console java import ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started