Homework 3 – Loops and Decision/Selection statements Solution
In this assignment, you will Design, C-code and Write a test plan for a program that performs the following task: Write your own unique program that does something in a loop that is flexible enough for any number of loops (i.e use a counter controlled loop and prompt for the number of loops or use a sentinel controlled loop). You loop must do some calculation inside (DO NOT just sum the loop counter). Your program must also include a Decision/Selection statement (i.e If structure). And finally display some kind of output. You may look at discussion 1 in Weeks 3,4,5 for some ideas. Some other suggestions: You may use the If structure to validate the user input. Or prompt the user if he is a Senior citizen and calculate a discount if so. There are 3 components of your submission including: DESIGN – Design your program using one of following three design tools: o Program Design (i.e. outline) - Make sure you include the start and end of the Loop and include any selection/decision conditions. o Pseudo-code – Design your program using the pseudo-code commands o Flowchart – Provide a flowchart for your design using the flowchart symbols that we learned in class. You can use Excel, Word, Powerpoint, Visio or any software you have available that will allow to draw shapes and connectors. TEST PLAN - Prepare at least 3 sets of input data (Test data) along with their expected output for testing your program. Make sure you test each part of your conditional test. Your test data can be presented in the form of a table as follows (note: feel free to adapt to your design. Note: A test set is one execution of the program - NOT one loop. C-code – submit your C-code as a separate file (.txt or .c) o Include a screen shot of the execution of you program. o Make sure your C-code is documented with Header and in-line comments and properly indented. The Design, Test Plan should be placed in a Word or PDF document for submission. Additional options: 1. You may add additional prompts if you like. Maybe purchase two items or prompt for the tax rate. 2. You may write out additional output such as the purchase amount, sales tax. 3. You may add addition test conditions if you like.