A5-Loopy Programs

On This Page


Overview

There are three parts to this assignment:

  1. Review Exercises:

    First make sure you have completed and turned in the exercises from lesson 5. Then complete the Review Exercises in CodeLab 5. These exercises will help prepare you for the problem-solving program and should be completed first.

  2. Problem Solving Program:

    Complete the programming projects following the Program Specifications listed below.

  3. Tutorial Exercises:

    Complete the Tutorial Exercises in CodeLab 5 before the specified due date. Refer to the assigned reading for the next lesson to help you understand the problems. Also, you can use the online lecture notes for more information as the notes become available. You can look at solutions if you miss your first attempt by clicking the "Solution" tab.

Program Specifications

General

  1. Note that you must complete these programs either by yourself or by working with one other student of this class following the rules of Pair Programming for Homework Assignments.
  2. Remember to follow all the style rules from the last assignments.
  3. Submit your files to Blackboard as explained in the section of this document: What to Turn In.

Number Analysis Program

  1. Complete Exercise P4.5 on page 176 of the textbook.
  2. The name of the source code file for this program must be numanalysis.cpp and all your code must be in this file.

    Be careful of the spelling, including capitalization, as you will lose points for a misspelled name.

  3. Your program must allow any number of entries and operate like this:
    This program analyzes numerical input.
    
    Enter a number (0 to exit): 1
    Enter a number (0 to quit): 2
    Enter a number (0 to quit): 3.5
    Enter a number (0 to quit): 7
    Enter a number (0 to quit): 0
    
    Average value: 3.375
    Smallest value: 1
    Largest value: 7
    Range: 6
    
Hint: Review the examples from lesson 5.3.3: Processing a Sequence of Inputs and Exercise 5.3. Also, look in the textbook at the example in "How To 4.1: Writing a Loop" on pages 154-156.

Finding a Minimum Input Value

  1. Complete Exercise P4.6 on page 176 of the textbook.
  2. The name of the source code file for this program must be minvalue.cpp and all your code must be in this file.

    Be careful of the spelling, including capitalization, as you will lose points for a misspelled name.

  3. Your program must allow any number of entries and operate like this:
    This program finds a minimum input value.
    
    Enter a number (Q to quit): 5
    Enter a number (Q to quit): 3.5
    Enter a number (Q to quit): 7
    Enter a number (Q to quit): -1.5
    Enter a number (Q to quit): q
    
    Minimum value: -1.5
    
  4. The program exits whenever the user enters a letter like q.
Hint: To exit a loop when entering a Q, or any other letter, check cin for failure during the loop.

Printing Squares

  1. Complete Exercise P4.20 on page 179 of the textbook.
  2. The name of the source code file for this program must be printsquares.cpp and all your code must be in this file.

    Be careful of the spelling, including capitalization, as you will lose points for a misspelled name.

  3. Your program must work for any width and operate like this:
    This program prints a filled and hollow square.
    
    Enter the length of a side: 5
    
    ***** *****
    ***** *   *
    ***** *   *
    ***** *   *
    ***** *****
    

    Also, you can see how the program operates by downloading and running the executable file: printsquares.exe.

  4. Your program must display a correct pair of squares for any positive integer length. Note that the squares may look odd when the combined lengths exceed the width of your console window.
Hints:
  • Review the example on Drawing Squares in lesson 5.2.2: Nested Loop Example: Drawing Squares.
  • You can make a hollow square by using an if statement inside an inner loop to decide when to print stars.
  • Develop test conditions for the if statement that allow the stars to print only at the start and end of the columns and rows.
  • Use an else clause to print spaces when not printing characters.
  • You may want to use two inner loops, one for each square, to simplify the logic.

Extra Credit

The following are worth extra credit points:

  1. Complete the assignment using pair programming. (1 point)
  2. Play the extra credit game shown below. (2 points)
    1. Complete the game through level 9
    2. Record the message shown at the beginning of level 10 in your README.txt under Extra Credit.
    3. Please do not cheat. If you get stuck, just explain how far you got in the README.txt and record the message for the level you completed.
    4. If you go beyond level 9, make certain to still record the message for the beginning of level 10

Make certain that your README.txt file describes any extra credit attempted.

Extra Credit Game

Ignore the "Loading" message. Press play to start the game. The first few levels are tutorials.

<a href="http://www.addictinggames.com/D78AQSAKQLQWI9/5145.swf" class="offsite" target="_blank">Go to the game</a>

Grading Criteria

The instructor will evaluate your assignment using the following criteria. Each criteria represents a specific achievement of your assignment and has a scoring guide. The scoring guide explains the possible scores you can receive.

Some scoring guides have a list of indicators. These indicators are a sign of meeting, or a symptom of not meeting, the specific criterion. Note that a single indicator may not always be reliable or appropriate in a given context. However, as a group, they show the condition of meeting the criterion.

For information on grading policies, including interpretation of scores, see the course information page.

Lesson Exercises

  • 2: All lesson exercises attempted and turned in
  • 1: Some lesson exercises completed and turned in
  • 0: No lesson exercises completed or turned in

Problem Solving Programs (x3)

  • 5: Demonstrates mastery of the program
    • Applies concepts from the lessons appropriately
    • Meets all specifications (see above)
    • Runs to completion with no abnormal error conditions
    • Generates correct output given correct input
    • Correct file name
  • 4: Has most of the functionality expected of the program
    • Demonstrates some techniques from the lesson
    • Attempts to meet all but one of the specifications (see above)
    • Implementation seems more complicated than necessary.
    • May have one minor error
  • 3: Has some of the functionality expected of the program
    • Demonstrates some techniques from the lesson
    • Attempts to meet at least 1/2 of the specifications (see above)
    • Implementation seems excessively complicated.
    • May have 2-3 minor errors
  • 2: Serious functional problems but shows some effort and understanding
    • Attempts to meet less than 1/2 of the of the specifications (see above)
    • Has a major error or many minor errors
    • Implementation seems very convoluted
    • Demonstrates few techniques from the lesson
  • 1: Does not compile or wrong file turned in
  • 0: Not turned in

Problem Solving Programs Style

  • 3: Code is well-documented including:
  • 2: Code has a minor documentation error
  • 1: Code has some documentation errors
  • 0: No apparent attempt to follow documentation standards or write documentation comments

CodeLab and Other Tutorial Exercises

  • Number CodeLab completed correctly / number exercises * 8 and rounded up to the nearest integer.

README.txt File

  • 2: README.txt file submitted following the instructions
  • 1: README.txt file submitted but some information was missing
  • 0: No README.txt file submitted

Total possible: 30, plus extra credit

What to Turn In

Submit your assignment to Blackboard, in the assignment folder that matches the name of this assignment, following the instructions for submitting homework. Include the following items for grading:

  1. README.txt file
  2. All the exercise files from Lesson 5
  3. numanalysis.cpp
  4. minvalue.cpp
  5. printsquares.cpp

You must submit all the files needed to complete your assignment. Your assignment must work as submitted.

Home | Blackboard | Day Schedule | Eve Schedule
Syllabus | Help | FAQ's | HowTo's | Links
Last Updated: March 16 2010 @19:47:39