Calculator Basic


public class calculator {

    public class Equals {

        public double add(double x, double y) {
            double z;
            z = x + y;
            return z;
        }

        public double mul(double x, double y) {
            double z;
            z = x * y;
            return z;
        }

        public double sub(double x, double y) {
            double z;
            z = x - y;
            return z;
        }

        public double div(double x, double y) {
            double z;
            z = x / y;
            return z;
        }

        public double type(String type, double x, double y) {
            if ("+".equals(type)) {
                double z;
                z = x + y;
                return z;
            } else if ("-".equals(type)) {
                double z;
                z = x - y;
                return z;
            } else if ("x".equals(type)) {
                double z;
                z = x * y;
                return z;
            } else if ("/".equals(type)) {
                double z;
                z = x / y;
                return z;
            }
            return 0;

        }
    }
}

3 thoughts on “Calculator Basic

  1. Wah blog ente ngeri, isinya kode2 alien.. saya seperti pernah mengerti kode2 ini? *hilang ingatan*

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s