Home‎ > ‎CS 11M‎ > ‎

Project 6: Coding With Functions

Objectives

  • Use functions in a program.
  • Use string variables in a program.
  • Use for-statements

Academic Honesty

Read the Scholastic Honesty Policy and Assignment Integrity policies of the syllabus. Here are some clarifications for this particular assignment:

  • You are expected to work either by yourself or with one other student of this class following the rules of Pair Programming for Homework Assignments.
  • You may NOT give a copy of your code to your designated pair-programming partner if you did not develop the code together.
  • You must breadboard the circuits yourself or with a pair-programming partner.
  • You may NOT look at another student's code until you complete and submit this assignment, except for code you develop together with your pair-programming partner.
  • You may get help from people other than your pair-programming partner if you get stuck, but only if they do not show or tell you the code to type.

Part 1: Month Names

Specifications

  1. Start with a new sketch

    File > New

  2. Save the sketch using the name month_names.
  3. Write a sketch that transforms the numbers 1, 2, 3, ..., 12 into the corresponding month names January, February, March, ..., December.
    9
    5
  4. Submit your month_names.ino file as part of this assignment.

Example Output

Enter the month number 9 Month 9 is September

Notes and Hints

  • The underlined font shows what is typed by the user in the text field at the top of the window.

Extra Credit

Update your function from Part 1 so that it works without an if or a switch statement. Hint: use create a funny looking string and use substring().

Part 2: Ohm's Law Calculator

In this project you write a program that calculates voltage, amperes or resistance using Ohm's law.

Specifications

  1. Start with a new sketch

    File > New

  2. Save the sketch using the name ohms_law.
  3. Write a program that calculates voltage, amperes or resistance using Ohm's law.
  4. The program offers three menu choices, as shown in the example run below.
  5. Depending on the choice, the program asks the user for the two dependent variables and then calculates the value.
  6. In your README.txt show the operation of your program with an example for all three menu choices, with the program name as a heading.

    See the Example Output below for an example, though you must use different values.

  7. Submit your ohms_law.ino file as part of this assignment.

Example Output

1. Calculate voltage (E) 2. Calculate amperes (I) 3. Calculate resistance (R) Enter the number of your choice 1 Calculating voltage using Ohm's law (E = IR) Enter current in Amperes (I) 2 Enter resistance in Ohms (R) 10 For 2.00 Amps and 10.00 Ohms the voltage is 20.00 Volts. 1. Calculate voltage (E) 2. Calculate amperes (I) 3. Calculate resistance (R) Enter the number of your choice 2 Calculating amperes using Ohm's law (I = E / R) Enter the voltage (E) 10 Enter resistance in Ohms (R) 5 For 10.00 Volts and 5.00 Ohms the current is 2.00 Amps. 1. Calculate voltage (E) 2. Calculate amperes (I) 3. Calculate resistance (R) Enter the number of your choice 3 Calculating resistance using Ohm's law (R = E / I) Enter the voltage (E) 10 Enter current in Amperes (I) 2 For 10.00 Volts and 2.00 Amps the resistance is 5.00 Ohms.

Notes and Explanations

  • The underlined font shows what is typed by the user in the text field at the top of the window.

Grading Criteria 

The instructor will evaluate your assignment using the following criteria. Thus you should check your assignment against these criteria to maximize your score.

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.

Project "month_names"

  • 5: Demonstrates mastery of the program
    • Applies concepts from the lessons appropriately
    • Meets all specifications
    • Runs as required 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
    • 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
    • Meets at least 1/2 of the specifications
    • Implementation seems excessively complicated.
    • May have 2-3 minor errors
  • 2: Serious functional problems but shows some effort and understanding
    • Meets less than 1/2 of the of the specifications
    • 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 or not original work

Project "ohms_law"

  • 10: Demonstrates mastery of the program
    • Applies concepts from the lessons appropriately
    • Meets all specifications
    • Runs as required with no abnormal error conditions
    • Generates correct output given correct input
    • Correct file name
  • 8: Has most of the functionality expected of the program
    • Demonstrates some techniques from the lesson
    • Attempts to meet all but one of the specifications
    • Implementation seems more complicated than necessary.
    • May have one minor error
  • 6: Has some of the functionality expected of the program
    • Demonstrates some techniques from the lesson
    • Meets at least 1/2 of the specifications
    • Implementation seems excessively complicated.
    • May have 2-3 minor errors
  • 3: Serious functional problems but shows some effort and understanding
    • Meets less than 1/2 of the of the specifications
    • 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 or not original work

Project Coding Style

  • 3: Code is well-documented and follows the specified coding styles
  • 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

How to Submit

Upload all project files to Canvas in the project folder that matches the name of this project. Include the following items for grading:

  1. This week's exercises:
    1. multiply.ino
    2. palindrome_function.ino
  2. month_names.ino
  3. ohms_law.ino

Submit your files on Canvas.

Comments