Posted: August 31st, 2021
Exception Handling, assignment help
Assessment Brief
Problem to compile below code in jgrasp, needs correctionimport java.util.Scanner;import java.util.InputMismatchException;class BadDataException extends Exception{ BadDataException(String str1) { super(str1); } public String tostring() { return "you entered a non digit "; }}class NumberHighException extends Exception{ public NumberHighException(String msg) { super(msg); } public String tostring() { return "NumberHighException: number > 100"; }}class NumberLowException extends Exception{ public NumberLowException(String msg) { super(msg); } public String tostring() { return "NumberLowException: number < 10"; }}class NumberNegativeException extends NumberLowException{ public NumberNegativeException(String msg) { super(msg); } public String tostring() { return "NumberNegativeException: number < 0"; }}class Verify{ int minim,maxm; Verify(int minim,int maxm) { this.minim = minim; this.maxm = maxm; } public void Validate(int num) throws Exception { if(num > 0 && num < minim) { throw new NumberLowException("NumberLowException:number < 10"); } if(num > maxm) { throw newNumberHighException("NumberHighException: number> 100"); } if(num < 0) { throw newNumberNegativeException("NumberNegativeException:number < 0"); } if(num >= minim && num <= maxm) { System.out.println(num+" is Within the Range"); } }}public class Program5{ public static void main(String args[]) throws Exception { System.out.println("Enter number b/w 10 to 100"); Scanner sc = new Scanner(System.in); try { int num = sc.nextInt(); Verify v = new Verify(10,100); v.Validate(num); } catch(InputMismatchException e) { throw new BadDataException("you entered a nondigit"); } }}
How Do You Vet Your Writers?
Our writers pass rigorous tests in their fields, have verified degrees, and undergo continuous training to ensure expertise. This ensures your paper is handled by a true professional. Our selective screening process maintains the highest standards of academic competence. You can trust our team to deliver top-quality work. Ace my homework with confidence knowing every writer meets stringent qualification standards.
Order | Check Discount
Tags: Research Essay Support, PhD Dissertation Help, Online Homework Help, Custom Essay Writing