CptS 111 Introduction to Algorithmic Problem Solving

Washington State University

Gina Sprint

PA1 Arithmetic (50 pts)

Due Monday, September 12 at Midnight.

Learner Objectives

At the conclusion of this programming assignment, participants should be able to:

  • Use variables, print() statements, and collect input from the user with input()
  • Convert values from one type to another (type casting)
  • Apply basic arithmetic

Prerequisites

Before starting this programming assignment, participants should be able to:

  • Run Python in interactive and script mode

Acknowledgments

Content used in this assignment is based upon information in the following sources:

  • No sources to cite

Overview and Requirements

For this programming assignment, we are going to write a basic chatbot program (chatbot.py). For fun, you can try having a conversation with an online chatbot here. The chatbot we are going to design wants to know a few things about you! Such as:

  1. What is your name?
  2. Where are you from?
  3. What is your favorite number?
  4. What is your dream car?
  5. How much does your dream car cost?

Program Details

Write a chatbot program that interacts with the user in the following manner:

  1. Find out the name of the user (string). Reply with a greeting, such as "It's so nice to meet you <user's name>! My name is <name of your chatbot>".
  2. Find out where the user is from (string). Reply with a positive statement, such as "<location> sounds like a pleasant place to be from!".
  3. Find out the user's favorite number (integer). Reply with a value that relates the user's favorite number to your favorite number, such as "Your favorite number (<user's favorite number>) is 1.5 times as big as my favorite number (7).
  4. Find out the user's dream car (string). Reply with a comment that expresses interest in the car, such as "Wow, I've always wanted a <car> as well.
  5. Find out how much the dream car costs (float). Then start a conversation about the cost of the car:
    1. A comment about how expensive the car is, such as "Gee, that is spendy."
    2. Find out how many years the user would take a loan out to pay for <car> (integer)
    3. Find out what annual interest rate (percent) the user expects to get for <car> (float)
    4. Reply with the expected monthly payment and total amount of money the user would pay for <car> (car price + interest), such as "Your monthly payment for the <car> is <monthly payment>, that is a total of <total cal cost>!.
  6. Say goodbye to <user's name>.

For calculating monthly payments, use the following formula:

$$mpymt = \frac{r(P)}{1 - (1 + r)^{-n}}$$

Where $r$ is the monthly interest rate, $P$ is the cost of the car, and $n$ is the number of monthly payments. You can figure out $r$ by converting the interest rate the user enters to a decimal (divide by 100) and then dividing by 12 (12 months in a year).

You can check your program output by comparing the computed monthly payment to an online payment calculator.

Example Run

Here is an example run of my "CarBot" program:

Hello there! My name is CarBot. What is your name? 
Jane Student
Hello Jane Student, it is great to meet you!
Jane Student, where are you from? 
Washington
Washington sounds like a pleasant place to grow up. Hmmmm, what else can I ask you... oh! What is your favorite number? 
23
Your favorite number (23) is 3.3 times as big as my favorite number (7)
What is your dream car? 
BMW i8
Wow, I have always wanted a BMW i8 as well. How much does a BMW i8 cost? 
141695
What is a reasonable yearly interest rate on a beautiful car like that? 
2.0
And if you had to take out a loan to buy the BMW i8, how many years would you take the loan out for? 
5
If you bought the BMW i8, you would have a monthly payment of $2483.60, hopefully that is reasonable for your budget. That's a total of $149015.76! I hope you can make the purchase!
Anyways, I gotta go. It's been nice chattin' with ya Jane Student :)

Note: BMW has a loan estimator on their website. Try it for the i8 to check your work! (Image from https://c2.staticflickr.com/8/7152/13650180553_2febc742d3_b.jpg)

Note: Your output does not have to exactly match mine above. It needs to be correct, but you are free to give your chatbot his/her own personality. Have fun with it!

Submitting Assignments

  1. Use the Blackboard tool https://learn.wsu.edu to submit your assignment to your TA. You will submit your code to the corresponding programming assignment under the "Content" tab in your lab course. You must upload your solutions as <your last name>_pa1.zip by the due date and time.
  2. Your .zip file should contain your .py file.

Grading Guidelines

This assignment is worth 50 points. Your assignment will be evaluated based on a successful compilation and adherence to the program requirements. We will grade according to the following criteria:

  • 5 pts for interacting with the user regarding their name
  • 5 pts for interacting with the user regarding where they are from
  • 10 pts for interacting with the user regarding their favorite number
  • 5 pts for interacting with the user regarding their dream car
  • 15 pts for correct loan payment computation
  • 5 pts for adherence to proper programming style and comments established for the class
  • 5 pts for giving your chatbot "personality", have fun!