Sei sulla pagina 1di 4

CS115 INTRODUCTION TO COMPUTER PROGRAMMING

Programming project #3: Automobile Advisor


INTRODUCTION
The goal of this programming assignment is to enable the student to practice programming using
functions.
PROBLEM DEFINITION:
Write a program that has four functions that do the following (identify parameters and/or
returned values for each function):
A main() function that has a loop that calls the other three functions until a user enters n in
response to the question, Do you have more automobile costs to calculate? (y/n)
An inputData() function to input vehicle owner name, monthly income, monthly car loan
payment, monthly car insurance, monthly gasoline cost, monthly amount put towards
maintenance including oil change and tires.
A computeExpenses() function to calculate the total of all the costs.
An adviseSellOrKeep() function to do the following:
If the total of costs is less than or equal to 20% of income then display:
Hey name your automobile costs of total_cost are within your means
You are advised to keep your vehicle

If the total cost exceeds 20% of income then display:


Hey name your automobile costs of total_cost are not affordable
You are advised to sell your vehicle

NOTE: name and total_cost will be replaced by the input and calculated value
respectively
Write a statement at the bottom of the program to call the main() function.
THE PYTHON PROGRAM
The program should do what is specified in the PROBLEM section above. The program should
have the following features:
1) The first few lines of your program should be comments that state the program name, the
authors (your) name, date the program is released, and a brief description of the main task
performed by the program.
2) Your program should have meaningful variable names. There should be a comment before
each function definition and at each major function point: input, calculation, output.

EXTERNAL DOCUMENTATION
Type a report of your solution in a Word or OpenOffice Writer document. You should structure
your document in four clear sections each with a subheading as follows:
1. PROBLEM DEFINITION
The problem definition comes here. This is a summary of the PROBLEM section above.
2. ANALYSIS
Give the variables that you have identified to hold output data and explain the type of data
for each variable. Similarly, give variables to hold input data and describe them. If any
calculations will be performed, give variables to store results of formulas. Also give
variables to hold constants.
Give formulas to convert input data to output data using variable names that you identified.
3. DESIGN
Give the algorithm in pseudocode form of the step by step statements to carry out the
required programming task in English phrases. Explain the reasoning of the structure and
logic of your program. You may use diagrams such as structure charts and flowcharts in
addition to the pseudocode to present hierarchy and logic of your program. Pseudocode
should not be in Python. Present separate pseudocode for each function. In pseudocode,
statements inside functions should be indented and statements inside loops or if else
should be further indented.
4. IMPLEMENTATION
What was the platform and programming environment used? Name the Operating System
and compiler. How did you test your program? Give the data used to test the program. Did
you encounter any unusual situations when running the program (For example, what
happens when an alphabetic character is input instead of an account number)?
*** You should not put your Python program in the external documentation ***

PROGRAM RUN RECORD


Run your program and save the program run session. For example, if you use IDLE you can
click on File on the menu and choose Save as then change the Save as type to Text files
before typing the file name and clicking on SAVE.
SUBMISSION METHOD [see APPENDIX for how to generate the documents]
a) Upload to Blackboard a copy of your external documentation.
b) Upload to Blackboard a copy of your program (not MS Word or PDF or RTF or WPS
formats but as generated by your editor saved with a .py extension).
c) A text file containing the record of the program run session.
You will click on the black words Programming project 3 in the Programming projects area
on Blackboard and then click on Browse My Computer then attach your external
documentation document, again click Browse My Computer and attach the program, and again
click Browse My Computer and attach the record of program run before finally clicking
SUBMIT.
GRADING
This program will be graded out of 100 points distributed as follows:
ITEM
MAX. POINTS
External documentation . . . . . . . . . . . . . . . . . . . . . . . . . 30
Style: comments, meaningful names . . . . . . . . . . . . . . 10
indentation
Program follows design spec & compiles error free . 30
Program works correctly . . . . . . . . . . . . . . . . . . . . . . . . 30

APPENDIX
There are three tasks as follows:
1) Read the PROBLEM DEFINITION and think what you will need and how you will
arrange statements.
a) Variables appear in formulas or hold data read from keyboard or calculated.
b) Imagine your program was running at on a computer. What would it do first, then second,
then third? Notice that order matters. For example, comparison based on input means
input comes first then comparison is done.
c) Your thought process is written in the ANALYSIS (variables and formulas) and
DESIGN (structure of functions and pseudocode) parts of the external documentation.
The order of tasks is presented using pseudocode.
2) Take the ideas you came up with in (1) above and put them into Python code. You can write
the Python code on paper first. Use your textbook to find examples of how to translate
pseudocode into Python. Next do the following assuming you are using IDLE.
a)
b)
c)
d)

Run IDLE
Click on File on the menu and select New file. This will open an editor.
Type your Python program in the editor.
Click File on the menu and then click Save as. Give your program a name (for
example automobileCostCalculator) and click Save. In this example it will be saved as
automobileCostCalculator.py

3) Next run your program and record a run session as follows:


a) In the editor window, click Run on the menu then select Run module. Your program
will run in the IDLE shell.
b) Type keyboard responses to your program and see what the program prints out.
c) Click on File on the shell window menu and select Save as. Change the Save file
type to Text files. Give a file name (for example automobileCostRun1).
d) Click Save. In this example the file will save with automobileCostCalcRun1.txt name.
This is a record of your program run saved to a text file

Potrebbero piacerti anche