Celsius Chase: Climbing to a Fiery Halt

Report a typo

Write a Java program that reads a sequence of temperature readings in degrees Celsius until a reading of 100 degrees or more is encountered. Your program should output the highest temperature reading observed up to that point. You must take input as a sequence of integer temperature values and print the highest value before the stopping condition.

HINT: Assume you are dealing only with positive temperatures.

Sample Input 1:

95
96
97
100

Sample Output 1:

97

Sample Input 2:

102

Sample Output 2:

0
Write a program in Java 17
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int maxTemperature = 0; // Initialize maximum temperature observed

// Add your while loop or do-while loop here to process input temperatures

// After exiting the loop, print the highest temperature
System.out.println(maxTemperature);

scanner.close(); // Close the scanner
}
}
___

Create a free account to access the full topic