Last active
July 14, 2021 16:13
-
-
Save codephillip/9d043c00cd66ada753b8d1d5e3e7a3cd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.codephillip.hello; | |
public class Main { | |
public static void main(String[] args) { | |
divider(); | |
} | |
} | |
import java.util.Scanner; | |
class DivideByZero4 { | |
public static void divider(){ | |
int numerator; | |
int denominator; | |
Scanner scan = new Scanner(System.in); | |
while(true){ | |
System.out.print("Enter numerator:"); | |
numerator = scan.nextInt(); | |
System.out.print("Enter denominator:"); | |
denominator = scan.nextInt(); | |
if(denominator == 0) | |
throw new DivideByZeroException("Zero Divisor"); | |
System.out.println("Answer "+numerator/denominator); | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment