CS 141 - Spring 2018

Program 1: Measurement Converter

Assigned: Friday, January 19
Due: Thursday, January 25, 2018 by 11:55pm (on Moodle)

Description

Your program will prompt the user for an floating point value representing miles/hour. You will reprint that value along with the value converted to the following values: Here's a list of definitions and measures you may need:

What you need to do

Start a new Python program (in a separate window, not the Python shell). Put a comment at the top with your name and a description of what the program does. Your comment should look like the standard program header shown here. Write the program so that it does the following:

Sample Interactions

What the computer displays (prints) is in regular text, what the user types is in bold, and what the program is doing behind the scenes is in italics.

Test 1

(Program begins) Please enter a speed in miles/hour: 1 Original speed in mph is: 1.0 Converted to barleycorn/day is: 4544016.55152 Converted to furlong/fortnight is: 2688.0 Converted to Mach number is: 0.0012979351032448377 Converted to percentage of speed of light: 1.4911612249060943e-09 (Program ends)

Test 2

(Program begins) Please enter a speed in miles/hour: 800 The original speed is: 800.0 Converted to barleycorn/day is: 3635213241.216 Converted to furlong/fortnight is: 2150400.0 Converted to Mach number is: 1.0383480825958702 Converted to percentage of speed of light: 1.1929289799248755e-06 (Program ends)

Test 3

(Program begins) Please enter a speed in miles/hour: 2.5 The original speed is: 2.5 Converted to barleycorn/day is: 11360041.3788 Converted to furlong/fortnight is: 6720.0 Converted to Mach number is: 0.003244837758112095 Converted to percentage of speed of light: 3.727903062265236e-09 (Program ends)
Your code does not need to follow this script verbatim, but all the mentioned functionality should work as shown.

Hints

Work out some examples on paper first to determine how the math works in this problem. Decide on what variables you need, what they represent in the problem, and what their data types should be. Test your program on lots of examples and make sure the math checks out.

How to get started

  • Create a Python program named yourlastname_yourfirstname_prg1.py
  • Follow the instructions for commenting your code.
  • Submit your Python file on Moodle under Program 1.
  • Requirements

    A good program will do all of the following:

  • Program file is named correctly.
  • Include the standard program header as a comment at the top of your program.
  • Prompt the user for the speed in miles/hour.
  • Calculate the correct conversions for each of the four units of measure.
  • Code is commented appropriately, is neatly and clearly formatted, and it includes proper use of 'white space'.
  • Challenge Problems

    From time to time, I will offer "challenge problems" on assignments. These problems are designed to have little (but some) impact on your grade whether you do them or not. You should think of these problems as opportunities to work on something interesting and optional, rather than a way to raise your grade through "extra credit."

    Policy on challenge problems:

    Challenge problems for this assignment:

    Grading

    Your program will be graded on correctness (whether your calculations are correct), as well as on coding style, which refers to choices you make when writing your code, such as good use of variable names, appropriate indentation, and comments (this is not an exhaustive list).

    You will receive one bonus point for every complete day your program is turned in early, up to a maximum of five points. For instance, if your program is due on September 20 at 11:59pm, if you turn in your code on Moodle any time on September 19 from 12:00am through 11:59pm, you will receive one extra point on your project. Programs submitted on September 18 from 12:00am through 11:59pm will receive two points. This pattern continues for up to five points.