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 10:00
Wich technology can a website use to allow you to listen to a concert live over the internet?
Answers: 3
question
Computers and Technology, 23.06.2019 04:31
Which of the following is not a way in which trees benefit the environment? a. they remove a significant amount of carbon dioxide from the atmosphere. b. they remove a significant amount of oxygen from the atmosphere. c. their roots hold soil in place, reducing rates of erosion. d. they remove ozone and particulates from the atmosphere. select the best answer from the choices provided a b c d
Answers: 1
question
Computers and Technology, 24.06.2019 04:30
The ieee 802.11: defines standards for wireless local area network (wlan) communication protocols. identifies various computers or devices connected to a network. verifies any resource attached to another computer on a network that is different from the computer to which the user is logged on. connects multiple local area networks (lans) and wide area networks (wans).
Answers: 2
question
Computers and Technology, 24.06.2019 10:30
Which of the following types of software is most applicable to the promotion of new products through advertising? a.databases b. spreadsheets c. web design programs d. word processing tools
Answers: 2
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: 13722361