import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;
public class TemperatureConsumer {
public static void main(String[] args) throws Exception {
// Create a Scanner object to read input from the command line
Scanner scanner = new Scanner(System.in);
// Prompt the user for temperature input in Celsius
System.out.print("Please enter the temperature in Celsius: ");
double celsius = scanner.nextDouble();
// Construct the URL with the entered temperature
String url = "http://localhost:8080/celsiusToFahrenheit?temp=" + celsius;
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
// Optional default is GET
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
// Print the result
System.out.println(response.toString());
// Close the scanner
scanner.close();
}
}