COS 100: Introduction to Programming
Interim 2022
HW Project 03: Counting credits
Due: 01/10 Mon 10pm
Now therefore, if you will indeed obey My voice and keep My covenant, then you shall be a special treasure to Me above all people; for all the earth is Mine. And you shall be to Me a kingdom of priests and a holy nation.
Exodus 19:5–6a
Project goal
You are to determine whether you are eligible to graduate and if so, whether you will graduate with honors. This program could replace a transactional aspect of a meeting with an academic advisor, and instead use that time to focus on more important issues such as calling, mission, and vocation.Project specification
-
Name your project source code
advising.py
. -
The full list of graduation requirements can be found in the Bethel Catalog (or by talking to your academic advisor).
We will use the following simplified rules:
- You must have at least 122 credits.
- You must take at least half of your major credits at Bethel.
- You must take at least 28 of your most recent 35 credits at Bethel.
- You must have a GPA of at least 2.0.
- If you verify that you are able to graduate, also determine whether you are eligible for honors based on these tables, which are different depending on whether a student has taken at least 68 credits at Bethel.
- Ask for each piece of info as a separate question.
- Make sure you don't ask the user for any information that isn't necessary. E.g., if the user indicates they don't have at least 122 credits, don't bother asking the other questions, because you already know they can't graduate.
- Don't ask for the same information more than once. E.g., if the user already told you their GPA, you should still remember it.
- Once you have all the necessary information, tell the user what their graduation status is.
Notes and hints
- Finish reading this entire document before you start.
- You can assume that the user will always answer with an integer for questions about credits, and a floating point number for questions about GPA. (Later we'll talk about what to do if the user enters unexpected input.)
- It is strongly recommended that you plan out your program before you start coding. Create a flowchart of all possible paths through your program to make sure you don't miss any cases. If you plan your program well, it can be very easy to code up. If you don't plan it well, you could end up with a much longer and messier program.
-
You can use
exit()
to quit early from the middle of a program:print("Greetings!") exit() print("Farewell!")
The above code will printGreetings!
and quit, without printingFarewell!
. Thonny might complain that there was aSystemExit
error. Worry not—that's not a real error. It simply signifies that your program didn't run until the end, but was exited in the middle.
Suggested order of development
This program is going to be longer than your previous program. The best approach is to plan it all out ahead of time, and then add just one or two pieces at a time, and test out what you just added before moving on. For example:- Create a program that only asks about whether you have 122 credits; check to make sure it behaves correctly.
- Add the question about credits for your major; test that just those two questions are working correctly in all their different combinations.
- Add a question about the most recent 35 credits, etc.
Sample runs
-
How many credits do you have? 128 How many credits does your major require? 54 Of those 54 credits, how many did you take at Bethel? 27 Of your most recent 35 credits, how many did you take at Bethel? 35 What is your GPA? 1.9 You need a higher GPA.
-
How many credits do you have? 130 How many credits does your major require? 52 Of those 52 credits, how many did you take at Bethel? 17 You need to take more major credits at Bethel.
-
How many credits do you have? 122 How many credits does your major require? 60 Of those 60 credits, how many did you take at Bethel? 54 Of your most recent 35 credits, how many did you take at Bethel? 32 What is your GPA? 3.75 How many of your credits did you complete at Bethel? 67 You graduate Cum Laude. Congratulations!
-
How many credits do you have? 122 How many credits does your major require? 30 Of those 30 credits, how many did you take at Bethel? 15 Of your most recent 35 credits, how many did you take at Bethel? 28 What is your GPA? 2.0 You graduate. Congratulations!
Grading
- Total points: 20
- Style: 2. From this project and onward, you will also be graded on coding style.
- At the top of your program, include your name and a brief description of its purpose,
- use descriptive variable names (e.g.,
credits
instead ofc
), - follow variable naming convention of
lowercase_words_with_underscores
orcamelCase
, - write comments as necessary,
- use blank lines to structure the code in paragraphs, and
- don't have excessively long lines.
- Correctness: 18.
- Follow the instructions as closely as you can. Read over the requirements in this document carefully, especially the project specification section.
- We will often try running your program with exactly the same sample inputs as above, so you should make sure your program works at least for those situations.
- But we will also run your program with other (valid but different) inputs, so your program should work in general, not specific to the examples above.
- We won't try to break your program by typing in invalid inputs, like answering
tofu
when a number is asked. - But we might try to break your program by typing in ridiculous inputs, like answering
55112
for the number of credits.
- We won't try to break your program by typing in invalid inputs, like answering
- Your program's output does not have to be exactly the same word for word: for example, I put spaces after my question marks; points won't be taken off if you don't.
- But your program should behave similarly: for example, at the very least, it should ask the same number of questions and respond with the same kinds of information.
- The easiest way is to try to match the exact output (you can even copy and paste the wording from the sample runs), but don't worry if you get a word misspelled or a punctuation misplaced.
Before moving on
Ponder how much care a programmer would need in order to implement policies and rules. Marvel at how much work must have gone into software like Degree Works that allow Bethel students (and advisors) to track your progress towards a degree. If you are employed by a bank to author an automated mortgage approval system based on various criteria, a tiny coding error could potentially affect many people's lives by erroneously declining their mortgage applications. With great power comes great responsibility.Start early, have fun, and discuss questions on Moodle.