Skip to content

Instantly share code, notes, and snippets.

@codephillip
Last active July 14, 2021 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codephillip/9d043c00cd66ada753b8d1d5e3e7a3cd to your computer and use it in GitHub Desktop.
Save codephillip/9d043c00cd66ada753b8d1d5e3e7a3cd to your computer and use it in GitHub Desktop.
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