- 4

Write a program that checks if the water is boiling. Take the integer temperature in Celsius as input and output "Boiling" .

Write a program that checks if the water is boiling. Take the integer temperature in Celsius as input and output "Boiling" if the temperature is above or equal to 100. I hAve tried coding the Above. It first stArted like this: temp= 110 if temp>= 100: print("Boiling") temp=99 if temp>=100: print("Boiling"). # This prints the Output Boiling. And I see A Green Tick MArk in the Output Section like #✔Test 1(which must meAn it is correct) . And then mArked ❌ in Test 2 with other result input = 99, expected output= No Output,but your Output is Boiling.

1st Feb 2021, 5:54 AM
We Doru
We Doru - avatar
30 Respuestas
+ 17
temp = int(input()) if temp >=76: print() if temp >=100: print("Boiling") try this code
25th Sep 2022, 9:02 AM
APPANNA VISHAL
+ 4
temp = int(100) if temp >= 100: print ("Boiling")✓ But Test case 1: And test case 4 are hidden showing errors So please help me can I take any input for test case 4
30th Sep 2022, 9:09 AM
Lovely Sairohith
+ 3
CAPITAL B FOR BOILING 🤦🏽‍♂️
20th Jan 2022, 1:50 AM
shattered Glass
+ 3
if temp >=76: print() if temp >=100: print("Boiling")
13th Oct 2022, 2:42 PM
Sumit Prajapati
Sumit Prajapati - avatar
+ 1
The parameter inside the input() is just a text that will appear on your interactive prompt or shell (it is not the value) and it is optional: Here is an example if I place a parameter, in interactive shell (not working in code playground): CODE: x = input("What is your name? ") print("Hello" + x) SHELL/PROMPT: >> What is your name? | # This will wait for your input, for example if I want to input "Red" >> What is your name? Red >> Hello Red
1st Feb 2021, 8:19 AM
noteve
noteve - avatar
+ 1
Scanner sc = new Scanner(System.in); int temp = sc.nextInt(); if(temp>=100){ System.out.println("Boiling"); } else { System.out.println("Not boiling"); }
26th Mar 2023, 11:23 AM
Vansh kumar
Vansh kumar - avatar
+ 1
The question describes a scenario where you need to create a program for a water sensor that checks if the water is boiling. The program should take an integer temperature in Celsius as input and then output "Boiling" if the temperature is equal to or above 100 degrees Celsius. If the temperature is below 100 degrees Celsius, the program should output "Not boiling." The question is asking you to write a Java program that performs this temperature check and prints the appropriate message based on the input temperature. import java.util.Scanner; public class Program { public static void main(String[] args) { //your code goes here Scanner scanner = new Scanner(System.in); int temperature = scanner.nextInt(); // Check if the temperature is above or equal to 100 if (temperature >= 100) { System.out.println("Boiling"); } else { System.out.println("Not boiling"); } } } Here's a step-by-step explanation of this answer: Import the Scanner class: The program starts by importing the java.util.Scanner class. This class allows you to read user input from the console. Create a Scanner object: The program creates a Scanner object named scanner to read user input. Read the temperature input: The program prompts the user to enter the temperature in Celsius. It reads the integer input using scanner.nextInt() and stores it in the variable temperature. Check if the water is boiling: The program uses an if statement to check if the temperature variable is greater than or equal to 100. If it is, the program prints "Boiling" using System.out.println(). Otherwise, it prints "Not boiling". For example, if the user enters a temperature of 105, the program will check the condition temperature >= 100, which evaluates to true. Therefore, it will output: Boiling This means that the water is boiling since the temperature is equal to or above 100 degrees Celsius. Credit: www.lawtantra.org
2nd Aug 2023, 6:48 AM
Novi
Novi - avatar
0
In challenges, you have to get the input: temp = int(input()) input() --> takes input as string int() --> converts the input string to integer
1st Feb 2021, 5:56 AM
noteve
noteve - avatar
0
But me writing temp=100 still should be correct, in terms of the python because integers cAn be written without quote and directly displayed As temp= 100.isn't this correct from the basic, but SoloLeArn shows wrong becauss they want us to follow the task exactly even though the way I put must be correct. Need clarification
1st Feb 2021, 6:02 AM
We Doru
We Doru - avatar
0
You don't need to type each input each test cases in challenges, just get the input and code to meet the expected output. # Try this: temp = int(input()) if temp >= 100: print("Boiling") # Think of the test cases as other people who will input something to test and judge your code. # If test cases 1 is 100 Your program will automatically get that 100 as input: temp = int(input()) <--- 100 (from test case) Same with other values temp = int(input()) <--- 99 (from test case)
1st Feb 2021, 6:08 AM
noteve
noteve - avatar
0
Alright, I tried this- temp = int(input(110)) if temp>=100: print("Boiling") #This prints out 110Boiling.
1st Feb 2021, 6:09 AM
We Doru
We Doru - avatar
0
Remove the 110 inside the int(input()), if you try that code on interactive prompt/shell, 110 will serve as your text input. However, in challenges we don't need one, we just have to get the input; temp = int(input())
1st Feb 2021, 6:11 AM
noteve
noteve - avatar
0
temp = int(100) if temp>=100: print("Boiling") temp= int(99) if temp>=100: print("Boiling"). It still gives me One output for the tAsk, thAt is Boiling. But I Also need No Output which is the expected Output of the chAllenge. Otherwise Test2 is still shown in ❌ MArk
1st Feb 2021, 6:28 AM
We Doru
We Doru - avatar
0
Just copy this one and paste to your solution, and maybe you'll understand: temp = int(input()) if temp >= 100: print("Boiling")
1st Feb 2021, 6:33 AM
noteve
noteve - avatar
0
Bonus Question:But exActly how. How did thAt if stAtement knows what to print without A prior variable being defined. For example I define a variable f = O. And then next I code if f=O , print(8). the mission will be Accomplished,but it All stArted from f=O. Is it due to the nature of python to identify 'temp' As temperature in degree celcius like it is A speciAl vAriable and not arbitrary one. Right . Why do the temp do not require no input in empty parenthes in temp = int(input()) .
1st Feb 2021, 6:48 AM
We Doru
We Doru - avatar
0
temp = int(input()) if temp > 99: print("Boiling")
15th Jul 2021, 9:57 AM
Elyor Azimov
Elyor Azimov - avatar
0
Finally worked it out
11th Sep 2021, 6:26 AM
Nick Suter
Nick Suter - avatar
0
temp = int(input()) if temp >= 100: print('Boiling') else: print(' ') in this program it will only print "Boiling" when the input temperature is above 100, else it won't print anything.
9th Apr 2022, 8:04 AM
Ishan Chaurasia
Ishan Chaurasia - avatar
0
ESTE ES EL CODIGO CORRECTO, ES LA SOLUCION¡¡¡ temp = int(input()) if temp >=76: print() if temp >=100: print("Boiling")
6th May 2022, 4:37 AM
David Del Angel Vazquez Calderon
0
temp = int(input()) if temp >= 100: print("Boiling") This code worked out for me just check it out.
12th Jun 2022, 2:48 PM
Ash Ketchum