![subject](/tpl/images/cats/informatica.png)
Computers and Technology, 07.08.2021 01:30 7841784
The given program reads a list of single-word first names and ages (ending with -1), and outputs that list with the age incremented.
The program fails and throws an exception if the second input on a line is a String rather than an Integer.
At FIXME in the code, add a try/catch statement to catch java. util. InputMismatchException, and output 0 for the age.
Ex: If the input is:
Lee 18
Lua 21
Mary Beth 19
Stu 33
-1
then the output is:
Lee 19
Lua 22
Mary 0
Stu 34
import java. util. Scanner;
import java. util. InputMismatchException;
public class NameAgeChecker {
public static void main(String[] args) {
Scanner scnr = new Scanner(System. in);
String inputName;
int age;
inputName = scnr. next();
while (!inputName. equals("-1")) {
// FIXME: The following line will throw an InputMismatchException.
// Insert a try/catch statement to catch the exception.
age = scnr. nextInt();
System. out. println(inputName + " " + (age + 1));
inputName = scnr. next();
}
}
}
![ansver](/tpl/images/cats/User.png)
Answers: 2
![](/tpl/images/ask_question.png)
![](/tpl/images/ask_question_mob.png)
Another question on Computers and Technology
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 22.06.2019 11:00
Which action is good business etiquette? a. switching your cell phone off before you enter a meeting b. keeping your cell phone on low volume before you enter a meeting c. setting a pleasant ring tone on your cell phone before you enter a meeting d. setting a standard ringtone on your cell phone before you enter a meeting
Answers: 1
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 22.06.2019 16:00
Why should characters such as / \ " ' * ; - ? [ ] ( ) ~ ! $ { } < > # @ & | space, tab, and newline be avoided in file names?
Answers: 2
![question](/tpl/images/cats/informatica.png)
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 24.06.2019 01:00
The initial tableau of a linear programming problem is given. use the simplex method to solve it. x 1 x 2 x 3 s 1 s 2 z 1 2 4 1 0 0 8 3 4 1 0 1 0 10 minus3 minus12 1 0 0 1 0 the maximum is nothing when x 1equals nothing, x 2equals nothing, x 3equals nothing, s 1equals3, and s 2equals0. (be sure to simplify to lowest terms if necessary.)
Answers: 2
You know the right answer?
The given program reads a list of single-word first names and ages (ending with -1), and outputs tha...
Questions
![question](/tpl/images/cats/fizika.png)
Physics, 04.05.2021 03:20
![question](/tpl/images/cats/pravo.png)
![question](/tpl/images/cats/mat.png)
Mathematics, 04.05.2021 03:20
![question](/tpl/images/cats/biologiya.png)
Biology, 04.05.2021 03:20
![question](/tpl/images/cats/biologiya.png)
Biology, 04.05.2021 03:20
![question](/tpl/images/cats/mat.png)
Mathematics, 04.05.2021 03:20
![question](/tpl/images/cats/biologiya.png)
Biology, 04.05.2021 03:20
![question](/tpl/images/cats/istoriya.png)
![question](/tpl/images/cats/obshestvoznanie.png)
![question](/tpl/images/cats/istoriya.png)
History, 04.05.2021 03:20
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/en.png)
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/mat.png)
Mathematics, 04.05.2021 03:20
![question](/tpl/images/cats/en.png)
English, 04.05.2021 03:20
![question](/tpl/images/cats/mat.png)
Mathematics, 04.05.2021 03:20
![question](/tpl/images/cats/en.png)
![question](/tpl/images/cats/en.png)
![question](/tpl/images/cats/mat.png)