subject

Write a program that prompts the user to read two integers and displays their sum . if anything but an integer is passed as input, your program should catch the inputmismatchexception that is thrown and prompt the user to input another number by printing " enter an integer ." sample run #1: java inputmismatchhere is the code i am using: import java. util. inputmismatchexception; import java. util. scanner; public class inputmismatch { public static void main(string[] args) { scanner scan = new scanner(system. in); while(true){try{system. out. printf("enter an integer: "); int firstnum = scan. nextint(); system. out. printf("enter an integer: "); int secondnum = scan. nextint(); int sum = firstnum + secondnum; system. out. print(sum); break; }

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 14:30
Create a pseudocode design to prompt a student for their student id and the titles of the three classes they want to add. the solution should display the student’s id and a total bill. • bill a student using the following rules: o students can only add up to 3 classes at a time.
Answers: 3
question
Computers and Technology, 22.06.2019 22:00
Competent nonverbal communication involves interacting with others in a manner that is appropriate for which of the following? select all that apply. situation task individuals
Answers: 3
question
Computers and Technology, 23.06.2019 09:30
:you areto design the controller for alight that functions both as an ordinary light and also as a motion activated light and alarm. a.if the manual switch s is on, then the light l is on. b.besides the manual switch, there is a motion detector, m1, which activatesthis light.c.if motion is detected but the light is on anyway because s is on, only then a secondoutput a, an alarm, is turned on. d.the disable switch, d, disables the motion activated light and alarmbut leaves manual control operation of the light using switch s.(i)read the problem statement and clearly identify the inputs and outputs for the circuit you are designing. (ii)create the truth table for this system; include the light, alarm, switch, disable, and the motion sensor.(iii)draw a schematic of this system.
Answers: 1
question
Computers and Technology, 23.06.2019 18:00
Freya realizes she does not have enough in her bank account to use the debit card. she decides to use a credit card instead. which questions should freya answer before using a credit card? check all that apply. can i pay at least the minimum payment each month? can i make payments on time and avoid late fees? will i have to take out a loan? how much in finance charges can i afford to pay? should i talk to a consumer credit counseling service?
Answers: 1
You know the right answer?
Write a program that prompts the user to read two integers and displays their sum . if anything but...
Questions
Questions on the website: 13722363