Difference between revisions of "CSC103 2011 Homework 3"

From dftwiki3
Jump to: navigation, search
 
(12 intermediate revisions by the same user not shown)
Line 1: Line 1:
<center>
+
<!--center>
 
<font size="+2">Page under construction!</font>
 
<font size="+2">Page under construction!</font>
 
<br \>[[File:UnderConstruction.jpg|300px]]
 
<br \>[[File:UnderConstruction.jpg|300px]]
</center>
+
</center-->
  
 
<br />
 
<br />
<bluebox>This homework is due on Monday, Feb. 21st, at 9:00 a.m.  You should make sure that you have gone through all the steps of  [[CSC103_2011_Lab_3| Lab #3]] as preparation for this homework.</bluebox>
+
<bluebox>This homework is due on <strike>Monday, Feb. 21st,</strike> Tuesday, Feb. 22nd, at 9:00 a.m.  You should make sure that you have gone through all the steps of  [[CSC103_2011_Lab_3| Lab #3]] as preparation for this homework.</bluebox>
 
<br />
 
<br />
 
__TOC__
 
__TOC__
 
<br />
 
<br />
 +
You may find the information in the following two documents very useful for working on this homework:
 +
* [http://math.hws.edu/TMCM/java/labs/xComputerLab1.html xComputer Lab 1]
 +
* [http://math.hws.edu/TMCM/java/labs/xComputerLab2.html xComputer Lab 2]
 +
 
=Problem #1=
 
=Problem #1=
  
 
* Use the Processor/Memory simulator and write a program that starts with 4 numbers stored in memory Locations 14, 15, 16, 17, and that stores the sum of all 4 in memory Location 18.
 
* Use the Processor/Memory simulator and write a program that starts with 4 numbers stored in memory Locations 14, 15, 16, 17, and that stores the sum of all 4 in memory Location 18.
  
* When you program works correctly, transcribe it on a piece of paper which you will submit as the solution to this homework.
+
* When you program works correctly, copy it to a text file of your choice.  Save the file for right now.
 +
 
 +
* Use labels in your program for instructions and for data (as described in [http://math.hws.edu/TMCM/java/labs/xComputerLab2.html xComputer Lab 2]).
 +
 
 +
* Try  to be efficient and attempt to use as few instructions as possible.
 +
 
 +
* Format your program neatly, so that all the labels start at the left margin, all the instructions are one above the other, all the comments (if any) one on top of the other.
  
 
=Problem #2=
 
=Problem #2=
  
* Write another program that computes the sum of the integers 1, 2, 3, 4, 5, 6, 7, 8, 9 and 10, and stores the sum in Memory Location 20 (or other convenient location).  Your program should stop when it has finished adding the number 10 to Memory Location 20.   
+
* Write another program that computes the sum of the integers 1, 2, 3, 4, 5, 6, 7, 8, 9 and 10, and stores the sum in a memory location labeled as '''sum'''.  Your program should stop when it has finished adding the number 10 to the location '''sum'''.   
 +
 
 +
* Make your program store the ten numbers 1, 2, 3, ... 10 in 10 different memory locations, and add them up to compute the sum
 +
 
 +
* Your program '''should''' stop when it is done.
 +
<br />
 +
 
 +
* As with Problem 1, copy your solution program at the end of the file you created for Problem 1.
 +
 
 +
=Problem #3=
 +
 
 +
* Same as Problem #2, but without storing the ten numbers in memory.  The program should generate all the numbers required in the accumulator, and use only 1 memory location to store data.
 +
 
 +
* As with Problem #2,  copy your solution at the end of the same file containing the other answers.
 +
 
 +
=Problem #4=
 +
 
 +
* Same as Problem #3, but your program this time will compute the sum of only the even numbers between 1 and 10.  In other words, make your program compute the sum of 2 plus 4, plus 6, plus 8, plus 10 using a loop.
 +
 
 +
* As with Problem #3, copy your solution at the end of the same file containing the other answers.
 +
 
 +
=Recommendations=
  
* You are free to write the program in one of two different ways:
+
* Programming is the art of writing complex instructions that a machine will have to execute. It can be very tedious to read computer code. The neater you are in writing your code, the more comments you add to your code, the easier it is to read and understand. 
*#The first option is to store the ten numbers 1, 2, 3, ... 10 in 10 memory locations, and add them up to compute the sum, or
+
* Make sure you write your code as neatly as possible!
*# write a loop that adds the 10 numbers by computing them and storing the sum in Memory Location 20. 
 
  
* Your program '''should''' stop automatically when it is done.
+
=Submission=
  
 +
* Email the file containing the solution to all 3 problems as an email message (no attachment, please!), and address it o '''103b@cs.smith.edu'''.  Make sure your name is at the top of the text of your message.
  
* As with Problem 1, copy your solution to a piece of paper that you will submit on the 21st, at 9:00 a.m.
 
  
  

Latest revision as of 23:39, 20 February 2011



This homework is due on Monday, Feb. 21st, Tuesday, Feb. 22nd, at 9:00 a.m. You should make sure that you have gone through all the steps of Lab #3 as preparation for this homework.



You may find the information in the following two documents very useful for working on this homework:

Problem #1

  • Use the Processor/Memory simulator and write a program that starts with 4 numbers stored in memory Locations 14, 15, 16, 17, and that stores the sum of all 4 in memory Location 18.
  • When you program works correctly, copy it to a text file of your choice. Save the file for right now.
  • Use labels in your program for instructions and for data (as described in xComputer Lab 2).
  • Try to be efficient and attempt to use as few instructions as possible.
  • Format your program neatly, so that all the labels start at the left margin, all the instructions are one above the other, all the comments (if any) one on top of the other.

Problem #2

  • Write another program that computes the sum of the integers 1, 2, 3, 4, 5, 6, 7, 8, 9 and 10, and stores the sum in a memory location labeled as sum. Your program should stop when it has finished adding the number 10 to the location sum.
  • Make your program store the ten numbers 1, 2, 3, ... 10 in 10 different memory locations, and add them up to compute the sum
  • Your program should stop when it is done.


  • As with Problem 1, copy your solution program at the end of the file you created for Problem 1.

Problem #3

  • Same as Problem #2, but without storing the ten numbers in memory. The program should generate all the numbers required in the accumulator, and use only 1 memory location to store data.
  • As with Problem #2, copy your solution at the end of the same file containing the other answers.

Problem #4

  • Same as Problem #3, but your program this time will compute the sum of only the even numbers between 1 and 10. In other words, make your program compute the sum of 2 plus 4, plus 6, plus 8, plus 10 using a loop.
  • As with Problem #3, copy your solution at the end of the same file containing the other answers.

Recommendations

  • Programming is the art of writing complex instructions that a machine will have to execute. It can be very tedious to read computer code. The neater you are in writing your code, the more comments you add to your code, the easier it is to read and understand.
  • Make sure you write your code as neatly as possible!

Submission

  • Email the file containing the solution to all 3 problems as an email message (no attachment, please!), and address it o 103b@cs.smith.edu. Make sure your name is at the top of the text of your message.