Saturday, October 19, 2019

HP 12C: Total Sales Tax with Rounded Amounts

HP 12C:  Total Sales Tax with Rounded Amounts




Introduction

The following program calculates the total invoice with the total sales tax.   Each time sales tax is calculated, the amount is rounded to two decimal places.

For example:

What is the total invoice for the purchase of three taxable items, if the sales tax is 9.5%. 

$19.95
$32.85
$47.50

The calculation:

19.95 + round(19.95 * .095,2)
+ 32.85 + round(32.85 * .095,2)
+ 47.50 + round(47.50 * .095,2)


= 19.95 + 1.90
+ 32.85 + 3.12
+ 47.50 + 4.51

= 109.83

Rounding to 2 Decimal Places 

The FIX 2 mode rounds results to 2 decimal places, but for the purposes the display only.  The number retains it's full decimal expansion.

When you want to use the rounded amount, we can use the following routine:

In fixed 2 mode:  [ f ] 2

...
1
EEX
2
*
ENTER   // makes a duplicate of the number
FRAC   // takes the fraction
.
5
x<>y   
x≤y   // is the fraction part less than 0.5
GTO  (A)   // go to line where (A) is

R↓  // fraction part is more than 0.5
+
GTO (B)

R↓   // (A)
R↓

ITNG  // (B), finalize the rounded number
1
EE
2
÷    // rounded number in the stack
...

Example:  425/118 = 3.60 in the display, shows 3601694915 when pressing [ f ] (PREFIX)

After this routine, we have 3.60, shows 3600000000 when pressing [ f ] (PREFIX)

Instructions:
1.  Enter the tax rate.
2.  Press [ f ] (PRGM), [R/S]
3.  Enter the item's cost, press [R/S]
4.  For subsequent items, enter the cost, then [R/S]
5.  When finished, press [RCL], 1 to recall total rounded sales tax.  Press [RCL], 2 to recall the total invoice.

I have program set to pause to show the rounded sales tax when each cost is entered. 

Program:
(Step ##: key code, key)
01:  44,0  STO 0
02:  42, 2  FIX 2
03:  35,  CLx
04:  44, 1 STO 1
05:  44, 2 STO 2
06:  31  R/S
07:  45, 0  RCL 0
08:  25   %
09:  1     1
10:  26   EE
11:  2     2
12:  20   *
13:  36   ENTER
14:  43, 24  FRAC
15:  48    .  (decimal point)
16:  5      5
17:  34   x<>y
18:  43, 34  x≤y
19:  43, 33, 23  GTO 23
20:  33   R↓
21:  40   +
22:  43, 33, 25   GTO 25
23:  33  R↓
24:  33  R↓
25:  43, 25  ITNG
26:  1    1
27:  26  EEX
28:  2     2
29:  10   ÷
30:  43, 31   PSE
31:  44, 40, 1   STO+ 1
32:  40   +
33:  44, 40, 2   STO+ 2
34:  31   R/S
35:  43, 33, 07  GTO 07

Example:
Sales Tax Rate:  9.5%
Item Costs:  $14.35, $18.99, $39.99, $23.64

Keystrokes:
9.5  [ f ] (PRGM) [R/S]
14.35 [R/S]
18.99 [R/S]
39.99 [R/S]
23.64 [R/S]

R1:  Total rounded sales tax:  9.21
R2:  Total invoice:  106.18

Eddie

All original content copyright, © 2011-2019.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.

TI 84 Plus CE: Consolidated Debts

TI 84 Plus CE: Consolidated Debts   Disclaimer: This blog is for informational and academic purposes only. Financial decisions are your ...