1 / 9

In The Name of God

In The Name of God. Calculator. Elnaz Barshan Fatemeh Torabi Asr Fahimeh Jamshidian Tehrani Maryam Sharifnia Leyla Kamkar.

darice
Download Presentation

In The Name of God

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. In The Name of God Calculator Elnaz Barshan Fatemeh Torabi Asr Fahimeh Jamshidian Tehrani Maryam Sharifnia Leyla Kamkar

  2. Capabilities:.calculation of ordinary expressions>>> 20*(3-1)+50 .saving given functions>>> def average(x,y): (x+y)/2 .saving values of constants>>> min=0.1 .offering mathematical important functions and constants>>> a=2+sin(pi) – (E)^2

  3. Classes: .Tree : a tool for saving a suitable form of an expression .Operation: containing important static methods .Macro: a tool for saving a suitable form of a function

  4. Treating a right input:>>>2+3*(50-9)+sin(2*pi) >>>min=(E)^0.1 >>>deff(x,y) : (x+y)/2 >>>m=3*f(2,4)+71 >>>f(3+m,5)>>>defg(a) : a+3 >>>garbages=g(f(5,1))

  5. Treating expressions:postfix=Operation.operate(expression)result=Operation.evaluate(postfix) Treating variables(=): dic.add(variable,resultOfexpression) Treating defs: macros.add(new Macro(def))

  6. Expression calculation:Operation.operate(String) makes the tree of expression reads the tree and makes the postfix Operation.evaluate(String[]) gets the postfix and returns the value evaluate works by the power of inheritance >>>

  7. Interface Opt{ double eval();}class Mul implements Opt { Opt a; Opt b; Mul(Opt a, Opt b) { this.a=a; this.b=b; } public double eval(){ return a.eval()*b.eval(); }}...class Mem implements Opt{ double x; Mem(String x){ Double d=new Double(x); this.x=d.doubleValue(); } public double eval(){ return x; }}

  8. Logical wrong and right input:>>>def f (x,y):g(x)+1>>>def f (x,y):g(5)+1>>>def sin(x):x+2*(x^2)>>>def sin(x,y):x+2*(y^2)>>>def f (1,7):1+7>>>def f (x,y):x+y>>>z=f (x,y)>>>z=f (2,5)>>>Pi=3.1>>>myPi=3.1>>>f (x,y)=x+y>>>def f (x,y):x+y

  9. This document and the executable file of the program are available on:http://pasargad.cse.shirazu.ac.ir/~torabi Tempbuffer/presentations/calculator …The end

More Related