Question: 1 1 . 1 2 LAB: Input errors with zyLabs Write a program that takes in three integers as inputs and outputs the largest value.
LAB: Input errors with zyLabs
Write a program that takes in three integers as inputs and outputs the largest value. Use a try block to perform all the statements. Use a catch block to catch any NoSuchElementException caused by missing inputs. Then output the number of inputs read and the largest value, or output No max" if no inputs are read.
Note: Because inputs are preentered when running a program in the zyLabs environment, the system throws the NoSuchElementException when inputs are missing. Test the program by running the program in the Develop mode.
Hint: Use a counter to keep track of the number of inputs read and compare the inputs accordingly in the catch block when an exception is caught.
Ex: If the input is:
the output is:
Ex: If the input is:
the system throws the NoSuchElementException and outputs:
inputs read: Max is
Ex: If no inputs are entered:
the system throws the NoSuchElementException and outputs:
inputs read: No max import java.util.Scanner;
import java.util.NoSuchElementException;
public class LabProgram
public static void mainString args
Scanner scnr new ScannerSystemin;
int val;
int val;
int val;
int max;
val;
val;
val;
Type your code here.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
