Created
May 20, 2020 00:01
-
-
Save Khuzha/01f45b21737f25ae61a2a455083cde56 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.io.IOException; | |
| import java.net.URI; | |
| import java.net.http.HttpClient; | |
| import java.net.http.HttpRequest; | |
| import java.net.http.HttpResponse; | |
| import java.util.Scanner; | |
| public class Calc { | |
| public static void main(String[] args) throws IOException, InterruptedException { | |
| Scanner scan = new Scanner(System.in); | |
| System.out.println("Введите пример:"); | |
| String expr = scan.next().replace("+", "%2B"); | |
| HttpClient client = HttpClient.newHttpClient(); | |
| HttpRequest request = HttpRequest.newBuilder() | |
| .uri(URI.create("http://api.mathjs.org/v4/?expr=" + expr)) | |
| .build(); | |
| HttpResponse<String> response = client.send(request, | |
| HttpResponse.BodyHandlers.ofString()); | |
| System.out.println(response.body()); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment