import java.util.Scanner;
import java.util.InputMismatchException;
public class Modulus{
public void calMod(double x) throws InputMismatchException{
Scanner inp= new Scanner(System.in);
System.out.println("Enter The Number You want to Calculate the Modulus Of");
x= inp.nextDouble();
if(x<0){
System.out.println("Modulus of |"+x+"| is");
x=-x;
System.out.println(x);
}
else{
System.out.println("Modulus of |"+x+"| is"+x);
}
}
public static void main(String[] args){
double x=0;
Modulus m= new Modulus();
try{
m.calMod(x);
}
catch(InputMismatchException ie){
System.out.println("Exception: The Entered value is not Numeric Type");
}
}
}
import java.util.InputMismatchException;
public class Modulus{
public void calMod(double x) throws InputMismatchException{
Scanner inp= new Scanner(System.in);
System.out.println("Enter The Number You want to Calculate the Modulus Of");
x= inp.nextDouble();
if(x<0){
System.out.println("Modulus of |"+x+"| is");
x=-x;
System.out.println(x);
}
else{
System.out.println("Modulus of |"+x+"| is"+x);
}
}
public static void main(String[] args){
double x=0;
Modulus m= new Modulus();
try{
m.calMod(x);
}
catch(InputMismatchException ie){
System.out.println("Exception: The Entered value is not Numeric Type");
}
}
}
No comments:
Post a Comment