A2-Implementing an Algorithm

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 2. Then complete the Review Exercises in CodeLab 2. These exercises will help prepare you for the problem-solving program and should be completed first.

  2. Problem Solving Program:

    Complete the programming project following the Program Specifications listed below.

  3. Tutorial Exercises:

    Complete the Tutorial Exercises in CodeLab 2 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.

Note: Make certain your program compiles before you turn it in. For all programming assignments, you should expect less than half credit if your program does not compile. When your program does not compile then it does not function either. For more information see the Grading Criteria.

Program Specifications

Note that this is an individual programming project and not a pair-programming project.

  1. Starting with your algorithm from assignment 1, develop a program that implements your algorithm.

    If you had difficulty with the algorithm, please discuss your algorithm with the instructor.

  2. The name of the source code file must be carcost.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. Prompt the user (using cout) and get the user input (using cin) for:
    1. The fuel efficiency of the car in MPG
    2. The cost of a gallon of gas
    Your program must display prompts like those shown and read the user input in order shown of the example run.

    Do not ask the user for any more information than these two data.

  4. Rather than the chalkboard, use variables to store the numbers.
  5. After displaying the cost, also display the carbon emitted by traveling 100 miles.

    Note that this was extra credit on the previous assignment, but is required for this assignment.

  6. The output of the program must look like this when run, including the exact labels for the total and average, for you to receive full credit:
    Car Travel Cost Calculator
    
    Enter the fuel efficiency of the car in MPG: 20.5
    Enter the cost of a gallon of gas: 2.25
    The cost of traveling 100 miles is: $10.9756
    The carbon emitted by traveling 100 miles is: 97.561 pounds
    
  7. Create a file comment block at the top of your source code formatted like the following:
  8. /**
        CS-11 Asn 2
        carcost.cpp
        Purpose: Calculates the cost and carbon emmitted when
        travelling 100 miles in a car.
    
        @author Ed Parrish
        @version 1.0 02/07/09
    */
    

    Use your own name and date, of course.

  9. Check your code to make certain that you have no tab characters.

    You can remove tab characters by either setting up TextPad correctly (see here) or by running a program named astyle (see here).

  10. In addition, make sure you have spaces before and after operators and after commas.
  11. Also, make sure your line length is 80 characters or less. TextPad and most other text editors tell you both the line and column location, which lets you make check the line length.
  12. Do not worry about magic numbers for this assignment.
  13. Use the default formatting and precision for the numbers -- do NOT add any formatting statements to the code.
  14. Submit your files to Blackboard as explained in the section of this document: What to Turn In.

Program Testing

Testing is an important part of software development and you need to test your program to see if it is working correctly. To help you know how your program should operate, you can download an executable version of the program using this link: carcost.exe. Run the program and try some inputs and check the outputs. Then make sure that your program runs the same way. Matching a set of known inputs to an expected output is known as a "test case".

Remember that to run the executable program, you must use the command line:

./carcost

Note that the download only works on Windows. If you are working on the Mac or Linux then you will need to develop your program using the example output shown in the specifications or run the downloaded program on a Windows computer in the classroom or CTC.

Extra Credit

The following is worth extra credit:

  1. Suppose we have a robot like the Roomba or Zoomba that we can program. Our robot can respond to the following commands:
    1. forward(amount)
    2. turnLeft(degrees)
    3. turnRight(degrees)

    We find a very dirty room and see an opportunity to use our cleaning robot artistically. We want our robot to vacuum the dirt of the floor, but in a geometric pattern like a square.

    List the sequence of commands would you give to the robot to draw a single square. Record your solution in the README.txt file you submit for this assignment. Be sure to label your algorithm write up as Extra Credit. (1 point)

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

Program Compilation

  • 4: Source code compiles with no errors or warnings
  • 3: Source code compiles with 1 warning
  • 2: Source code compiles with 2 warnings
  • 1: Source code compiles with 3+ warnings
  • 0: Does not compile or wrong file turned in

Program Functionality

  • 10: Demonstrates mastery of the assignment
    • Applies concepts from the lessons appropriately
    • Meets all specifications (see above) with particularly elegant solutions
    • Runs to completion with no abnormal error conditions
    • Generates correct output given correct input
  • 8: Has all the functionality expected of the assignment
    • Demonstrates many techniques from the lesson
    • Attempts to meet all specifications (see above)
    • Implementation seems more complicated than necessary.
    • May have one minor error
  • 6: Has most of the functionality expected of the assignment
    • Demonstrates some techniques from the lesson
    • Attempts to meet all but one of the specifications (see above)
    • Implementation seems excessively complicated.
    • May have 2-3 minor errors
  • 4: Has some of the functionality expected of the assignment
    • Demonstrates some techniques from the lesson
    • Attempts to meet at least 1/2 of the specifications (see above)
    • Implementation seems excessively complicated.
    • May have more than 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
  • 0: Does not execute

Program Style

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

CodeLab Exercises

Number 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 2
  3. carcost.cpp

Your assignment must work as submitted, so make sure you double-check what your files. Once the due date is past, you cannot change any files and I grade you on what you turn in.

Home | Blackboard | Announcements | Day Schedule | Eve Schedule
Course info | Help | FAQ's | HowTo's | Links
Last Updated: February 28 2009 @18:09:49