Skip to content

Files

Latest commit

Mar 12, 2015
ca9f28c · Mar 12, 2015

History

History
112 lines (73 loc) · 3.12 KB

2015-03-07_week-0-review.md

File metadata and controls

112 lines (73 loc) · 3.12 KB

Week 0 Review

Link to Slides

###Objectives

  • Have a standard Git + IntelliJ workflow
  • Know what .gitignore is and how to use it
  • Understand the Java package structure (review)
  • Understand the different components of a Java program (review)
  • Know the basic Java types and understand when to use them (review)
  • Know how to get user input using Scanner (review)
  • Know when and how to use an if statement (review)

###Review

  • Git + IntelliJ
  • a Java program
  • Variables + Types
  • User Input
  • If statements

###Exercises

  • Try to finish as many as you can!
  • After every exercise, commit your work to GitHub!

Madlibs

This program should prompt the user for a minimum of six inputs (text inputs with at least one number) and then print out your "mad lib" result! Here is a sample partial run:

Sample input:

  Enter an adjective: purple
  Enter another adjective: ancient
  Enter a noun: dragon
  Enter another noun: spoon

Sample output:

  Here is your mad lib!!
  The purple bear went into the ancient house.
  There she saw a dragon and a spoon.

Reverse Polish Notation Calcultator

Write a Reverse Polish notation calculator! Reverse Polish notation is a mathematical notation where the operator comes after the two operands, like this 2 3 +, which evaluates to 5. Your task is to write a class RPNCalculator that prompts the user for two numbers and a mathmetical operator and then returns the correct result.

Your calculator should support the following operations:

  • a + b
  • a - b
  • a / b
  • a * b
  • a % b

Here is an example:

"Please enter your first number"
3
"Please enter your second number"
7
"Please enter an operator"
-
"Result: -4"

A second example:

"Please enter your first number"
12
"Please enter your second number"
12
"Please enter an operator"
+
"Result: 24"

Your calculator only needs to handle 3 user inputs: 2 ints and 1 operator. You may test an RPN calculator here.

More fun with user input + if statements

  • Write a program that responds to different greetings

  • Write a command line fortune teller that responds to your questions

###OUR FIRST GAME

Make your own command line adventure game!

===============

###More exercises

User Input

A Dumb Calculator

  • Printing the result here can be tricky!

BMI Calculator

What if

How Old Are You?

If

Else and If

A little quiz

  • Come up with your own questions and answers
  • How can you keep track of the number of correct and incorrect answers?