CS 230 Fall 2006

Assignment 5 –Looping

100 points

 

Assigned: 10/04/2006

Due: 10/11/2006 at the start of class

 

Pre-Lab (Do Before Lab):  Bring a new disk. Plan out tasks, objects, and events needed for program. Plan out major pseudocode

 

Main Assignment:

Radioactive material has a “half-life” – the amount of time it takes ½ of the material to decay. This is true regardless of how much material there is. For instance, Fluorine-20 has a half life of 11 seconds. So if there is 100 grams of Fluorine-20, after 11 seconds there will be 50 grams, after 22 seconds there will be 25 grams, after 33 seconds there will be 12.5 grams, after 44 seconds there will be 6.25 grams, etc.  Write a program that simulates the decay radioactive material. Get from the user the beginning amount of material, the half-life, and the number of half-lives to simulate. Display in a RichTextBox (see below) for each half-life elapsed, the time elapsed to that point and the amount of material remaining. After the given number of half-lives, display in labels or read-only textboxes the final total time elapsed and remaining material. NOTE – this task should be done with a loop.  

 

Provide capabilities to calculate, clear the input and output to start again, and to exit.

 

Hand in:

 

Miscellaneous:

·         You must turn on Option Explicit and Option Strict.

·         If you have any questions about how radioactive half-life works, please ask!!! Your calculations need to meet the requirements of the task.

·         To add items to the rich text box, use richtextboxname.AppendText( a string ). You can build a string out of pieces using “concatenation” . E.g.  “Material: “ & material.toString(“n3”) & ControlChars.NewLine

(The ControlChars.NewLine moves the next info after to a new line). To clear the contents of a list box, use richtextboxname.Clear()

·         We’re no longer going to assume that the clerk enters valid and reasonable values, so ensure that values entered are numbers and that they are in acceptable range. Let’s assume that amount of material, half-life, and number of half-lives to simulate all should be positive, and number of half-lives should be a whole number

·         MAKE SURE YOUR PROGRAM WORKS! (i.e. gets the correct answers). Now that our program is branching and looping, we need to try more examples to make sure they work. Think, “what different possibilities need to be checked?” For each, calculate the correct answer by hand and see if your program gets it!

·         Make sure you save your work before running your program. It is possible that an “infinite loop” could have to be terminated. Usually that will be ok, but if you ever had to kill VB using the task manager you could lose unsaved work.

·         Put YOUR NAME, e-mail address, date, and purpose of the program in comments at the beginning of the program.

·         You MUST include comments that explain your program in order to get full credit.

·         Remember to use meaningful variable names, and indent to show the structure of the program (VB usually does this correctly).

·         Put your name on the form as a Label or as part of the form title.

·         Try to use good user interface design.