Question: (1) Read the current temperature from the user and store it into the variable temperature . Example If the input is: 80 The output should
(1) Read the current temperature from the user and store it into the variable temperature.
Example
If the input is:
80
The output should be:
What temperature is it? The current temperature is 80
(2) Extend the output to show "degrees" after the temperature, and to output a newline after the output.
Example
If the input is:
80
The output should be:
What temperature is it? The current temperature is 80 degrees
import java.util.Scanner; // required for user input
public class SimpleInput { public static void main(String[] args) { int temperature = 0; Scanner scnr = new Scanner (System.in); // required for user input System.out.println("What temperature is it? "); /* Type code to read temperature here. */ System.out.print("The current temperature is " + temperature); return; } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
