A2-Implementing an Algorithm

On This Page


Overview

Complete the following for full credit on the assignment:

  1. Lesson Exercises

    Make sure you have completed the exercises from lesson 2.

  2. Review Lab Exercises:

    Complete the Review Exercises in CodeLab 2. These exercises will help prepare you for the problem-solving program and should be completed first.

  3. Problem Solving Program:

    Complete the programming project following the Program Specifications listed below.

  4. Tutorial Lab 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.

  5. Turn in Files

    Submit your files to Blackboard as explained in the section of this document: What to Turn In.

Note: Make certain your program compiles before you turn it in. When your program does not compile then it does not function either. For all programming assignments, you should expect less than half credit if your program does not compile. 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 the order shown by 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:
    /**
        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.

  8. 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 check the line length.

  9. In addition, make sure you indent your code inside main() (see: Indentation).
  10. Also, make sure your variable names are descriptive and follow one of the acceptable formats (see: Naming Conventions).
  11. Use the default formatting and precision for the numbers -- do NOT add any formatting statements to the code.

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. Complete Exercise P2.3 (P2.1) on page 66 of the textbook. The name of the source code file for this program must be math.cpp and you must turn in the source code file. (2 points)

    Hint: the pow() function is described on page 42 of the textbook.

  2. Use the default formatting and precision for the numbers -- do NOT add any formatting statements to the code.

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 syllabus 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
  4. Optionally, math.cpp (extra credit)

You must submit all the files needed to complete your assignment. Your assignment must work as submitted. Remember to test and double check your files before submitting them. If you make a mistake, you can resubmit up to the deadline. If you have problems uploading to Blackboard, see: How do I upload my assignment files?.

Home | Blackboard | Day Schedule | Eve Schedule
Syllabus | Help | FAQ's | HowTo's | Links
Last Updated: February 19 2012 @19:27:44