Skip to content

Instantly share code, notes, and snippets.

@elenawalom
Forked from bridgpal/w1d2-homework.md
Created June 19, 2013 00:09
Show Gist options
  • Save elenawalom/5810667 to your computer and use it in GitHub Desktop.
Save elenawalom/5810667 to your computer and use it in GitHub Desktop.

#Homework for June 18, 2013

##Calculator 1 Create a command line calculator. It should have a basic and advanced mode.

basic calculator (+, -, *, /) advanced calculator (exponents, square root)

For a basic calculator, press 1.
For an advanced calculator, press 2. To quit, press Q.
For calculators, first enter type of calculation, then enter 2 numbers.

Create methods for each operation, and each one to show and interact with a text menu.

##Calculator 2

Add a trip calculator to your program. Ask the user (politely) for four inputs:

Distance – how far will you drive?
MPG – what is the fuel efficiency of the car?
$PG – how much does gas cost per gallon?
Speed – how fast will you drive?

Your output is a string: “Your trip will take 3.5 hours and cost $255.33.”

Add this as a menu choice.

##Bonus

Add two more sets of calculators. These should be accessible from your menu method that you created in Calculator 1.

  • Mortgage:

    • Calculate the monthly payment when given the other variables as input.
      Inputs: principal, yearly interest rate, number of payments
      Output: Monthly mortage payment
  • BMI:

    • Calculate the BMI when given the height and weight.
      Input: weight, height
      Output: BMI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment