Courses‎ > ‎AP Computer Science 2‎ > ‎konstantinovich‎ > ‎

2018-04-17

posted Apr 17, 2018, 10:18 AM by Konstantinovich Samuel   [ updated Apr 18, 2018, 10:01 AM ]
AP baron's review book: (an older one for more practice questions!)

In school:

Outside of school:
google this, and it will be the 2nd result:  
ap computer science baron's book pudaloff

Regarding the AP:
We will do some AP review! 
We are not focussing on AP review. If you want to do your best, you must do a significant amount of review on your own.
The AP Exam always has simple solutions to the coding section, keep it simple, don't over-engineer solutions.
Review your AP documentation, what is/isn't on the exam.
I strongly recommend you read through any new-ish baron's book if you haven't done so. The old ones are fine, but may have slightly out of date class definitions.
As always: there is no grid world! Ignore it.


For AP Practice Multiple choice Questions: 
Time yourself! 
- Write all of your choices, and any scrap work you did on looseleaf. 
- Try to do it in 2 sittings giving yourself the correct amount of time total. 
- Go over the solutions after. Put a STAR next to questions you need to discuss in class. Write a note about why you were confused.

Homework: (Some questions have issues because they use old java standards)
Diagnostic Exam A ( Starts on PDF page 19)
Multiple Choice Questions 1-33  (34-40 are not on the AP and not part of this class)

Homework: (Some questions have issues because they use old java standards)
Practice Exam 3 (starts on PDF page 627)
Multiple Choice Questions 1-34  (35-40 are not on the AP and not part of this class)

What is/isn't on the AP:

Quick Reference: (1st page only!)


GOAL: Evaluate a post fix expression

Evaluate an arbitrary postfix expression. Assume all results are doubles (do not have to preserve int when you run an operation on two ints)

valid numbers:
any int or double.

valid operators: (all binary)
+
-
*
/
%

All values and operators are separated by a single space:
"10 2.0 +"
"11 3 - 4 + 2.5 *"
"8 2 + 99 9 - * 2 + 9 -"

Write the eval(String) method, that will correctly evaluate a post-fix expression.

eval("10 2.0 +") is 12.0
eval("11 3 - 4 + 2.5 *") is 30.0
eval("8 2 + 99 9 - * 2 + 9 -") is 893.0

Use the build in LinkedList or the ArrayList to do this assignment!
Write a simple stack class that has a push/pop to make your code look nicer. 

1. Convert your string into tokens. (A list of values and operators)
1b. Test this by printing each one!
2. Instead of printing each one, decide what to do with them... using a stack!

What is/isn't on the AP:

Quick Reference: (1st page only!)


GOAL: Evaluate a post fix expression

Evaluate an arbitrary postfix expression. Assume all results are doubles (do not have to preserve int when you run an operation on two ints)

valid numbers:
any int or double.

valid operators: (all binary)
+
-
*
/
%

All values and operators are separated by a single space:
"10 2.0 +"
"11 3 - 4 + 2.5 *"
"8 2 + 99 9 - * 2 + 9 -"

Write the eval(String) method, that will correctly evaluate a post-fix expression.

eval("10 2.0 +") is 12.0
eval("11 3 - 4 + 2.5 *") is 30.0
eval("8 2 + 99 9 - * 2 + 9 -") is 893.0
The order is left to right just like scheme : "3 2 -" is 1


Github
/09StackCalculator/

public class Calculator{
    public static double eval(String s){}
}

Assume valid postfix notation.
Comments