summaryrefslogtreecommitdiff
path: root/projects/10/ArrayTest/Main.xml
diff options
context:
space:
mode:
Diffstat (limited to 'projects/10/ArrayTest/Main.xml')
-rw-r--r--projects/10/ArrayTest/Main.xml286
1 files changed, 286 insertions, 0 deletions
diff --git a/projects/10/ArrayTest/Main.xml b/projects/10/ArrayTest/Main.xml
new file mode 100644
index 0000000..0ea96df
--- /dev/null
+++ b/projects/10/ArrayTest/Main.xml
@@ -0,0 +1,286 @@
+<class>
+ <keyword> class </keyword>
+ <identifier> Main </identifier>
+ <symbol> { </symbol>
+ <subroutineDec>
+ <keyword> function </keyword>
+ <keyword> void </keyword>
+ <identifier> main </identifier>
+ <symbol> ( </symbol>
+ <parameterList>
+ </parameterList>
+ <symbol> ) </symbol>
+ <subroutineBody>
+ <symbol> { </symbol>
+ <varDec>
+ <keyword> var </keyword>
+ <identifier> Array </identifier>
+ <identifier> a </identifier>
+ <symbol> ; </symbol>
+ </varDec>
+ <varDec>
+ <keyword> var </keyword>
+ <keyword> int </keyword>
+ <identifier> length </identifier>
+ <symbol> ; </symbol>
+ </varDec>
+ <varDec>
+ <keyword> var </keyword>
+ <keyword> int </keyword>
+ <identifier> i </identifier>
+ <symbol> , </symbol>
+ <identifier> sum </identifier>
+ <symbol> ; </symbol>
+ </varDec>
+ <statements>
+ <letStatement>
+ <keyword> let </keyword>
+ <identifier> length </identifier>
+ <symbol> = </symbol>
+ <expression>
+ <term>
+ <identifier> Keyboard </identifier>
+ <symbol> . </symbol>
+ <identifier> readInt </identifier>
+ <symbol> ( </symbol>
+ <expressionList>
+ <expression>
+ <term>
+ <stringConstant> HOW MANY NUMBERS? </stringConstant>
+ </term>
+ </expression>
+ </expressionList>
+ <symbol> ) </symbol>
+ </term>
+ </expression>
+ <symbol> ; </symbol>
+ </letStatement>
+ <letStatement>
+ <keyword> let </keyword>
+ <identifier> a </identifier>
+ <symbol> = </symbol>
+ <expression>
+ <term>
+ <identifier> Array </identifier>
+ <symbol> . </symbol>
+ <identifier> new </identifier>
+ <symbol> ( </symbol>
+ <expressionList>
+ <expression>
+ <term>
+ <identifier> length </identifier>
+ </term>
+ </expression>
+ </expressionList>
+ <symbol> ) </symbol>
+ </term>
+ </expression>
+ <symbol> ; </symbol>
+ </letStatement>
+ <letStatement>
+ <keyword> let </keyword>
+ <identifier> i </identifier>
+ <symbol> = </symbol>
+ <expression>
+ <term>
+ <integerConstant> 0 </integerConstant>
+ </term>
+ </expression>
+ <symbol> ; </symbol>
+ </letStatement>
+ <whileStatement>
+ <keyword> while </keyword>
+ <symbol> ( </symbol>
+ <expression>
+ <term>
+ <identifier> i </identifier>
+ </term>
+ <symbol> &lt; </symbol>
+ <term>
+ <identifier> length </identifier>
+ </term>
+ </expression>
+ <symbol> ) </symbol>
+ <symbol> { </symbol>
+ <statements>
+ <letStatement>
+ <keyword> let </keyword>
+ <identifier> a </identifier>
+ <symbol> [ </symbol>
+ <expression>
+ <term>
+ <identifier> i </identifier>
+ </term>
+ </expression>
+ <symbol> ] </symbol>
+ <symbol> = </symbol>
+ <expression>
+ <term>
+ <identifier> Keyboard </identifier>
+ <symbol> . </symbol>
+ <identifier> readInt </identifier>
+ <symbol> ( </symbol>
+ <expressionList>
+ <expression>
+ <term>
+ <stringConstant> ENTER THE NEXT NUMBER: </stringConstant>
+ </term>
+ </expression>
+ </expressionList>
+ <symbol> ) </symbol>
+ </term>
+ </expression>
+ <symbol> ; </symbol>
+ </letStatement>
+ <letStatement>
+ <keyword> let </keyword>
+ <identifier> i </identifier>
+ <symbol> = </symbol>
+ <expression>
+ <term>
+ <identifier> i </identifier>
+ </term>
+ <symbol> + </symbol>
+ <term>
+ <integerConstant> 1 </integerConstant>
+ </term>
+ </expression>
+ <symbol> ; </symbol>
+ </letStatement>
+ </statements>
+ <symbol> } </symbol>
+ </whileStatement>
+ <letStatement>
+ <keyword> let </keyword>
+ <identifier> i </identifier>
+ <symbol> = </symbol>
+ <expression>
+ <term>
+ <integerConstant> 0 </integerConstant>
+ </term>
+ </expression>
+ <symbol> ; </symbol>
+ </letStatement>
+ <letStatement>
+ <keyword> let </keyword>
+ <identifier> sum </identifier>
+ <symbol> = </symbol>
+ <expression>
+ <term>
+ <integerConstant> 0 </integerConstant>
+ </term>
+ </expression>
+ <symbol> ; </symbol>
+ </letStatement>
+ <whileStatement>
+ <keyword> while </keyword>
+ <symbol> ( </symbol>
+ <expression>
+ <term>
+ <identifier> i </identifier>
+ </term>
+ <symbol> &lt; </symbol>
+ <term>
+ <identifier> length </identifier>
+ </term>
+ </expression>
+ <symbol> ) </symbol>
+ <symbol> { </symbol>
+ <statements>
+ <letStatement>
+ <keyword> let </keyword>
+ <identifier> sum </identifier>
+ <symbol> = </symbol>
+ <expression>
+ <term>
+ <identifier> sum </identifier>
+ </term>
+ <symbol> + </symbol>
+ <term>
+ <identifier> a </identifier>
+ <symbol> [ </symbol>
+ <expression>
+ <term>
+ <identifier> i </identifier>
+ </term>
+ </expression>
+ <symbol> ] </symbol>
+ </term>
+ </expression>
+ <symbol> ; </symbol>
+ </letStatement>
+ <letStatement>
+ <keyword> let </keyword>
+ <identifier> i </identifier>
+ <symbol> = </symbol>
+ <expression>
+ <term>
+ <identifier> i </identifier>
+ </term>
+ <symbol> + </symbol>
+ <term>
+ <integerConstant> 1 </integerConstant>
+ </term>
+ </expression>
+ <symbol> ; </symbol>
+ </letStatement>
+ </statements>
+ <symbol> } </symbol>
+ </whileStatement>
+ <doStatement>
+ <keyword> do </keyword>
+ <identifier> Output </identifier>
+ <symbol> . </symbol>
+ <identifier> printString </identifier>
+ <symbol> ( </symbol>
+ <expressionList>
+ <expression>
+ <term>
+ <stringConstant> THE AVERAGE IS: </stringConstant>
+ </term>
+ </expression>
+ </expressionList>
+ <symbol> ) </symbol>
+ <symbol> ; </symbol>
+ </doStatement>
+ <doStatement>
+ <keyword> do </keyword>
+ <identifier> Output </identifier>
+ <symbol> . </symbol>
+ <identifier> printInt </identifier>
+ <symbol> ( </symbol>
+ <expressionList>
+ <expression>
+ <term>
+ <identifier> sum </identifier>
+ </term>
+ <symbol> / </symbol>
+ <term>
+ <identifier> length </identifier>
+ </term>
+ </expression>
+ </expressionList>
+ <symbol> ) </symbol>
+ <symbol> ; </symbol>
+ </doStatement>
+ <doStatement>
+ <keyword> do </keyword>
+ <identifier> Output </identifier>
+ <symbol> . </symbol>
+ <identifier> println </identifier>
+ <symbol> ( </symbol>
+ <expressionList>
+ </expressionList>
+ <symbol> ) </symbol>
+ <symbol> ; </symbol>
+ </doStatement>
+ <returnStatement>
+ <keyword> return </keyword>
+ <symbol> ; </symbol>
+ </returnStatement>
+ </statements>
+ <symbol> } </symbol>
+ </subroutineBody>
+ </subroutineDec>
+ <symbol> } </symbol>
+</class>