Presentation is loading. Please wait.

Presentation is loading. Please wait.

Assignment #3 Programming Language, Spring 2003

Similar presentations


Presentation on theme: "Assignment #3 Programming Language, Spring 2003"— Presentation transcript:

1 Assignment #3 Programming Language, Spring 2003
Calculator Assignment #3 Programming Language, Spring 2003

2 Specification (1) Calculator Application. Only integer arithmetic
The operations are addition, subtraction and multiplication Use an arbitrary number of variables whose names are A,B,C,D,E. Main way of doing calculations To type in a few formulas and to assign them to variables Some formulas are complicated expressions, which can refer to yet undefined variables, while other formulas consist of a single number Then asks for the value of some variables Redefine some variables and then to reevaluate formulas that depend on these variables

3 Specification (2) Arithmetic Assignment Print Reset var := expression
PRINT var Reset RESET

4 Assignment Objectives Implement calculator
Input a few formulas and etc. Then answer the value of some variables asked for For each ``PRINT'' statement found in the input file Output a line containing the numerical value of the specified variable Or the word ``UNDEF'' if the variable is undefined

5 Input Convention Input file Contain a few formulas and etc. Example
A := B + C B := 3 C := 5 PRINT D PRINT A B := 8 RESET A := 1 + ( 2 + ( 3 + ( * 6 ) * 7 ) * 8 ) PRINT B

6 Output Convention Output file
For each ``PRINT'' statement found in the input file Output a line containing the numerical value of the specified variable Or the word ``UNDEF'' if the variable is undefined Example UNDEF 8 13

7 Source Code calculator.scm Output value of the specified variable
Input formulas and etc. calculator.in Output value of the specified variable calculator.out

8 Spec. Assignment Spec. System Unix Language Scheme (MIT Scheme)


Download ppt "Assignment #3 Programming Language, Spring 2003"

Similar presentations


Ads by Google