subject
Computers and Technology, 09.02.2021 23:50 nez45

INSTRUCTIONS 1. Pind & fix the syntax error so program will compile
2. Run program entering different whole number inputs to discover the logic error
3. Modify program so that it works correctly
4. Run the program entering decimal input to cause a runtime error (InputMismatchException)
5. Modify program so it won't crash with decimal input
import java. util. Scanner;
public class Temperature
public static void main(String[] args)
{
1/Variable declaration
double temp = 0;
//Instantiating a Scanner object to get user input
Scanner sc = new Scanner(System. in);
//Get temperature from user
System. out. print("Enter a temperature: ");
temp - sc. nextInt();
//Display message based on temperature
if (temp <= 32)
System. out. println("It's freezing.");
if (temp < 50)
System. out. println("It's cold.");
if (temp < 80)
System. out. println("It's warm.");
if (temp < 100);
System. out. println("It's hot.");
else
System. out. println("It's extremely hot!");
> //end main
}//end class

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 15:00
In the blank libreoffice writer document, to start the process of entering a date field into a letter, click on the insert menu. edit menu. file menu. fields menu.
Answers: 3
question
Computers and Technology, 24.06.2019 12:50
Write a new lc-3 trap subroutine (i.e. a subroutine that will be invoked via the trap instruction) that will receive a numeric digit entered at the keyboard (i.e. an ascii character), echo it to the screen, and return in r0 the corresponding numeric value: so if the user types the digit '7', the character '7' will appear on the screen, but the value returned in r0 will be b0000 0000 0000 0111 (#7) you may not use any trap calls in your code - you must implement the "polling" code that interrogates the keyboard status and data registers. ; getnum_tsr ; a subroutine for obtaining a numeric value ; given ascii numeric digit input to keyboard. ; the numeric digit is echoed to the console (e.g. '7' = b0000 0000 0011 0111), ; but the value returned in r0 is the actual numeric value ; corresponding to the digit (e.g. b0000 0000 0000 0111 =
Answers: 3
question
Computers and Technology, 24.06.2019 13:10
Write a program that has a conversation with the user. the program must ask for both strings and numbers as input. the program must ask for at least 4 different inputs from the user. the program must reuse at least 3 inputs in what it displays on the screen. the program must perform some form of arithmetic operation on the numbers the user inputs. turn in your .py file as well as a screenshot of your program's output. include comments in your code to explain how it works an example program run might look like (have fun with this and be creative): โ€˜what is your name? โ€™ โ€œjoshโ€ โ€˜, josh. what is your favorite color? โ€™ โ€œgreenโ€ โ€˜mine too. do you also like ice cream? โ€™ โ€œnoโ€ โ€˜josh, how old are you? โ€™ โ€œ40โ€ โ€˜ and how many siblings do you have? โ€™โ€™ โ€œ3โ€ โ€˜that means you are one of 4 kid(s). is green the favorite color of anyone else in your house? โ€™
Answers: 3
question
Computers and Technology, 24.06.2019 20:30
Where is permanent data in the computer stored whenever gym starts his laptop he sees some commands in numbers appearing on the screen these instructions are being preceded by the control unit in
Answers: 1
You know the right answer?
INSTRUCTIONS 1. Pind & fix the syntax error so program will compile
2. Run program enteri...
Questions
question
English, 24.09.2020 22:01
Questions on the website: 13722363