advertisement
Section 8
Programming Basics
Why Use Programs?
A program is simply a sequence of keystrokes that is stored in the calculator.
Whenever you have to calculate with the same sequence of keystrokes several times, you can save a great deal of time by incorporating these keystrokes in a program. Instead of pressing all the keys each time, you press just one key to start the program: the calculator does the rest automatically!
Creating a Program
Creating a program consists simply of writing the program, then storing it:
1. Write down the sequence of keystrokes that you would use to calculate the quantity or quantities desired.
2. Select the mode you want to use (by pressing f] or f[).
Note:
Programs or steps created and saved in RPN mode should only be executed in RPN mode, and programs or steps created and saved in ALG mode should only be executed in ALG mode. (You can also create steps in your program to switch to the appropriate mode.)
3. Press fs to set the calculator to Program mode. When the calculator is in Program mode, functions are not executed when they are keyed in, but instead are stored inside the calculator. The PRGM status indicator in the display is lit when the calculator is in Program mode.
4. Press fCLEARÎ to erase any previous programs that may be stored inside the calculator. If you want to create a new program without erasing a program already stored, skip this step and proceed as described in Section
11, Multiple Programs.
5. Key in the sequence of keystrokes that you wrote down in step 1. Skip the beginning keystrokes that enter data, which would differ each time the program is used.
104
File name: hp 12c pt_user's guide_English_HDPMF123E27 Page: 104 of 275
Printed Date: 2005/8/1 Dimension: 14.8 cm x 21 cm
Section 8: Programming Basics 105
Example: Your office supplies dealer is selling selected stock at 25% off. Create a program that calculates the net cost of an item after the discount is subtracted and the $5 handling charge is added.
First, we’ll manually calculate the net cost of an item listing for $200.
Keystrokes
(RPN mode)
Display
200
\
200.
200.00
25b
-
5
+
50.00
150.00
5.
155.00
Keys in cost of item.
Separates cost of item from percentage to be keyed in next.
Amount of discount.
Price less discount.
Handling charge.
Net cost (price less discount plus handling charge).
Keystrokes
(ALG mode)
200
-
Display
200.
200.00
25b
+
5
}
50.00
150.00
5.
155.00
Keys in cost of item.
Separates cost of item from percentage to be keyed in next.
Amount of discount.
Price less discount.
Handling charge.
Net cost (price less discount plus handling charge).
Next, set the calculator to Program mode and erase any program(s) already stored:
Keystrokes Display fs fCLEARÎ 000,
Sets calculator to Program mode.
Clears program(s).
Finally, press the keys that we used above to solve the problem manually. Do not key in 200; this number will vary each time the program is used. Don’t be concerned right now about what appears in the display as you press the keys; we’ll discuss that later in this section.
File name: hp 12c pt_user's guide_English_HDPMF123E27 Page: 105 of 275
Printed Date: 2005/8/1 Dimension: 14.8 cm x 21 cm
advertisement
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Key Features
- Financial Pocket Black, Silver
- 10 digits
- Memory registers: 20
Related manuals
advertisement
Table of contents
- 3 Introduction
- 3 About This Handbook
- 4 Financial Calculations in the United Kingdom
- 4 For More Solutions to Financial Problems
- 15 Problem Solving
- 16 Getting Started
- 16 Power On and Off
- 16 Low-Power Indication
- 16 Adjusting the Display Contrast
- 16 The Keyboard
- 17 Keying in Numbers
- 17 Digit Separators
- 17 Negative Numbers
- 18 Keying in Large Numbers
- 18 Backspacing
- 19 The CLEAR Keys
- 20 Undo Operation
- 20 The RPN and ALG Keys
- 21 Simple Arithmetic Calculations in RPN Mode
- 22 Simple Arithmetic Calculations in ALG Mode
- 23 Chain Calculations in RPN Mode
- 26 Chain Calculations in ALG Mode
- 26 Parentheses Calculations
- 27 Storage Registers
- 27 Storing and Recalling Numbers
- 29 Clearing Storage Registers
- 29 Storage Register Arithmetic
- 31 Percentage and Calendar Functions
- 31 Percentage Functions
- 31 Percentages in RPN Mode
- 32 Percentages in ALG Mode
- 33 Net Amount in RPN Mode
- 33 Net Amount in ALG Mode
- 34 Percent Difference
- 35 Percent of Total in RPN Mode
- 36 Percent of Total in ALG Mode
- 37 Calendar Functions
- 37 Date Format
- 38 Future or Past Dates
- 40 Number of Days Between Dates
- 41 Basic Financial Functions
- 41 The Financial Registers
- 41 Storing Numbers into the Financial Registers
- 41 Displaying Numbers in the Financial Registers
- 42 Clearing the Financial Registers
- 42 Simple Interest Calculations
- 44 Financial Calculations and the Cash Flow Diagram
- 46 The Cash Flow Sign Convention
- 46 The Payment Mode
- 47 Generalized Cash Flow Diagrams
- 49 Compound Interest Calculations
- 49 Interest Rate
- 49 Calculating the Number of Payments or Compounding Periods
- 55 Calculating the Periodic and Annual Interest Rates
- 56 Calculating the Present Value
- 58 Calculating the Payment Amount
- 60 Calculating the Future Value
- 63 Odd-Period Calculations
- 69 Amortization
- 72 Additional Financial Functions
- 72 Discounted Cash Flow Analysis: NPV and IRR
- 73 Calculating Net Present Value (NPV)
- 78 Calculating Internal Rate of Return (IRR)
- 79 Reviewing Cash Flow Entries
- 80 Changing Cash Flow Entries
- 82 Bond Calculations
- 82 Bond Price
- 83 Bond Yield
- 84 Depreciation Calculations
- 86 Additional Operating Features
- 86 Continuous Memory
- 87 The Display
- 87 Status Indicators
- 87 Number Display Formats
- 88 Scientific Notation Display Format
- 90 Special Displays
- 90 Key in RPN Mode
- 91 Arithmetic Calculations With Constants
- 92 Recovering From Errors in Digit Entry
- 93 Statistics Functions
- 93 Accumulating Statistics
- 94 Correcting Accumulated Statistics
- 96 Standard Deviation
- 97 Linear Estimation
- 99 Weighted Mean
- 100 One-Number Functions
- 102 The Power Function in RPN Mode
- 102 The Power Function in ALG Mode
- 103 Programming
- 104 Programming Basics
- 104 Why Use Programs?
- 104 Creating a Program
- 106 Running a Program
- 108 Program Memory
- 108 Identifying Instructions in Program Lines
- 109 Displaying Program Lines
- 112 000 Instruction and Program Line
- 112 Expanding Program Memory
- 114 Setting the Calculator to a Particular Program Line
- 114 Executing a Program One Line at a Time
- 117 Interrupting Program Execution
- 117 Pausing During Program Execution
- 122 Stopping Program Execution
- 125 Branching and Looping
- 125 Simple Branching
- 126 Looping
- 129 Conditional Branching
- 139 Program Editing
- 139 Changing the Instruction in a Program Line
- 140 Adding Instructions at the End of a Program
- 142 Adding Instructions within a Program
- 142 Adding Instructions by Replacement
- 144 Adding Instructions by Branching
- 149 Multiple Programs
- 149 Storing Another Program
- 153 Running Another Program
- 155 Solutions
- 156 Real Estate and Lending
- 156 Annual Percentage Rate Calculations With Fees
- 159 Price of a Mortgage Traded at a Discount or Premium
- 161 Yield of a Mortgage Traded at a Discount or Premium
- 163 The Rent or Buy Decision
- 169 Deferred Annuities
- 171 Investment Analysis
- 171 Partial-Year Depreciation
- 171 Straight-Line Depreciation
- 176 Declining-Balance Depreciation
- 180 Sum-of-the-Years-Digits Depreciation
- 184 Full- and Partial-Year Depreciation with Crossover
- 191 Excess Depreciation
- 192 Modified Internal Rate of Return
- 194 Black-Scholes Formula for Valuing European Options
- 202 Leasing
- 202 Advance Payments
- 202 Solving for Payment
- 206 Solving for Yield
- 209 Advance Payments With Residual
- 209 Solving for Payment
- 212 Solving for Yield
- 213 Savings
- 213 Nominal Rate Converted to Effective Rate
- 215 Effective Rate Converted to Nominal Rate
- 216 Continuous Rate Converted to Effective Rate
- 217 Bonds
- 217 30/360 Day Basis Bonds
- 222 Annual Coupon Bonds
- 227 Appendices
- 228 Appendix A: RPN and the Stack
- 230 Termination of Digit Entry
- 230 Stack Lift
- 230 Rearranging Numbers in the Stack
- 231 One-Number Functions and the Stack
- 231 Two-Number Functions and the Stack
- 231 Mathematics Functions
- 232 Percentage Functions
- 233 Calendar and Financial Functions
- 234 Chain Calculations in RPN Mode
- 235 Arithmetic Calculations with Constants
- 237 Appendix B: Algebraic Mode (ALG)
- 237 Simple Arithmetic Calculations in ALG Mode
- 238 Chain Calculations in ALG Mode
- 239 Key in ALG Mode
- 239 The History Stack in ALG Mode
- 240 Parentheses Calculations
- 241 Percentage Functions
- 241 Percent Difference
- 242 Percent of Total
- 242 The Power Function
- 245 Appendix D: Error Conditions
- 245 Error 0: Mathematics
- 246 Error 1: Storage Register Overflow
- 246 Error 2: Statistics
- 246 Error 3: IRR
- 246 Error 4: Memory
- 247 Error 5: Compound Interest
- 248 Error 6: Storage Registers
- 248 Error 7: IRR
- 249 Error 8: Calendar
- 249 Error 9: Service
- 249 Pr Error
- 250 Appendix E: Formulas Used
- 250 Percentage
- 250 Interest
- 250 Simple Interest
- 251 Compound Interest
- 251 Amortization
- 252 Discounted Cash Flow Analysis
- 252 Net Present Value
- 252 Internal Rate of Return
- 252 Calendar
- 252 Actual Day Basis
- 252 30/360 Day Basis
- 253 Bonds
- 254 Black-Scholes Formula for Valuing European Options
- 254 Depreciation
- 255 Straight-Line Depreciation
- 255 Sum-of-the-Years-Digits Depreciation
- 255 Declining-Balance Depreciation
- 256 Modified Internal Rate of Return
- 256 Advance Payments
- 256 Interest Rate Conversions
- 256 Finite Compounding
- 256 Continuous Compounding
- 257 Statistics
- 257 Weighted Mean
- 257 Linear Estimation
- 257 Standard Deviation
- 257 Factorial
- 258 The Rent or Buy Decision
- 259 Battery
- 259 Low-Power Indication
- 260 Installing a New Battery
- 261 Verifying Proper Operation (Self-Tests)
- 263 Warranty
- 264 Service
- 265 Regulatory Information
- 266 Temperature Specifications
- 266 Noise Declaration
- 266 European Union
- 267 Appendix G: United Kingdom Calculations
- 267 Mortgages
- 268 Annual Percentage Rate (APR) Calculations
- 268 Bond Calculations
- 269 Function Key Index
- 272 Programming Key Index
- 274 Subject Index