Write two programs in the Bare Bones programming language, as described in Section 11.3 of Brookshear's Computer Science: An Overview, 8e, and test them using Mike Huffman's BareBones Interpreter (as corrected by J. Mohr).
Write a Bare Bones program that does the equivalent of the following Java code:
if ( x != 0 )
y = 1;
else
z = 1;
Write a Bare Bones program that sets variable z to the minimum of x and y, where x and y have been set to arbitrary non-negative integer values.
Because the program could produce many lines in the output window and the z might receive its final value in the "middle" of the program execution rather than near the end, please put the following two Bare Bones commands at the end of your program:
incr z; decr z;
This will ensure that the last value printed in the output window is the final value of variable Z.
You may use the convenient addition to the Bare Bones language that is supported by Huffman's BareBones interpreter:
set name n;
For example, the first two lines of your program to determine the minimum of the values of x and y could be:
set x 3; set y 5;
This will make it much easier to test your program with the values of x and y reversed, or with them equal.
Use a text editor such as TextPad to design and write your programs, then highlight the text of your program in the editor and copy and paste it into the program box of the BareBones interpreter. This should help you to avoid accidentally erasing all your work.
Be sure there is a newline (carriage return) at the end of the last line, or the BareBones interpreter will not correctly read the last line.
The first program -- implementing an if statement -- will be worth 4 points, and the second -- determining the minimum of two integers -- will be worth 6 points.
Submit your programs by copying and pasting them into the text boxes of the form below.
You may submit the form multiple times if you wish to correct errors in previous form submissions or to add information to the form. However, if you resubmit the form, you must re-enter both programs. Your last submission will be accepted for grading.
Your assignment submissions are password-protected. These passwords apply only to form data submitted via the Web server for Jonathan Mohr's courses. They are separate from (and typically different from) your network password or the password. To change your Web password, press the following button:
Copyright © 2004 Jonathan Mohr