Make Advanced Calculator By Programing Kid

                 
                    Advanced Calculator 

package com.google;

import java.util.Scanner;

class DivException extends Exception {
    @Override
    public String toString() {
        return "You Can't Divide By 0";
    }

    @Override
    public String getMessage() {
        return " Please Don't Try Next time ";
    }
}

class invalException extends Exception {
    @Override
    public String toString() {
        return "This is Invalid We can't try";
    }

    @Override
    public String getMessage() {
        return " Please Don't Try Next time ";
    }
}

class MaxException extends Exception {
    @Override
    public String toString() {
        return "Your value Grater 100000 One Lakh";
    }

    @Override
    public String getMessage() {
        return " Please Don't Try Next time ";
    }
}

class MaxMulException extends Exception {
    @Override
    public String toString() {
        return "You Can't Multiply Grater Than 7000";
    }

    @Override
    public String getMessage() {
        return " Please Don't Try Next time ";
    }
}

public class Advancedcalculator {
    public static void main(String[] args) {

Start();
    }
    public static void Start() {
        System.out.println("Made By Abhijeet Bissa ");
        System.out.println();
        Scanner scan = new Scanner(System.in);
System.out.println("Enter Sing Of OPRETION Do you Want");
String sing =scan.nextLine();
if(sing.equals("*") || sing.equals("-")  ||sing.equals("+")  ||sing.equals("/") ){

}
else{
    try {
        throw new invalException();
    } catch (Exception e) {
        System.out.println(e.toString());
        System.out.println(e.getMessage());
        e.printStackTrace();
        Start();
    }
}
System.out.println("Enter 1 Digit Do you OPRETION");
int fdig =scan.nextInt();
System.out.println("Enter 2 Digit Do you OPRETION");
int fdig2 =scan.nextInt();


if(sing.equals("*")){

    if (fdig >=7000) {
        try {
            throw new MaxMulException();
        } catch (Exception e) {
            System.out.println(e.toString());
        System.out.println(e.getMessage());
        e.printStackTrace();
        Start();
        }
       
    } else {
        if (fdig2 >=7000) {
            try {
                throw new MaxMulException();
            } catch (Exception e) {
                System.out.println(e.toString());
            System.out.println(e.getMessage());
        e.printStackTrace();
           
            Start();
            }
           
        }
        else{
            Multipication(fdig,fdig2);
        }
    }    

}
else{






if (fdig >= 100000) {
    try {
        throw new MaxException();
    } catch (Exception e) {
        System.out.println(e.toString());
    System.out.println(e.getMessage());
    System.out.println("try again");
    e.printStackTrace();
   
    Start();
    }
   
} else {
    if (fdig2 >=100000) {
        try {
            throw new MaxException();
        } catch (Exception e) {
            System.out.println(e.toString());
        System.out.println(e.getMessage());
        System.out.println("try again");
        e.printStackTrace();
   
        Start();
        }
       
    }
    else{
        if (sing.equals("/")) {
            if (fdig == 0 && fdig2 ==0 ) {
                try {
                    throw new DivException();
                } catch (Exception e) {
                 System.out.println(e.toString());
                 System.out.println(e.getMessage());
                 e.printStackTrace();
   
                 Start();


                }
               
            }
            else {
                if (fdig == 0) {
                    try {
                        throw new DivException();
                    } catch (Exception e) {
                     System.out.println(e.toString());
                     System.out.println(e.getMessage());
                     e.printStackTrace();
   
                     Start();
   
   
                    }
                   
                }
                else{
                    Division(fdig, fdig2);
                    Start();
                }  
        }
           
        }
        else{
            if (sing.equals("+")) {
                Plus(fdig, fdig2);
                Start();
            } else {
                if (sing.equals("-")) {
                    Subtract(fdig, fdig2);
                    Start();
                }
                else{
                   
   
                }  
               
            }
        }
    }
}
}}
       
   

    public static void Division(int z, int y) {
System.out.println(y/z);
Start();
    }

    public static void Multipication(int z, int y) {
System.out.println(z*y);
Start();
}

    public static void Subtract(int z, int y) {
        System.out.println(z-y);
        Start();
    }

    public static void Plus(int z, int y) {
        System.out.println(z+y);
        Start();
    }
}

Comments