About this task
You can use arithmetic expressions in
a program many different ways.
The following example uses several arithmetic operators to round and
remove extra decimal places from a dollar and cents value.
Figure 1. Example Using Arithmetic Expressions/****************************** REXX *********************************/
/* This program computes the total price of an item including sales */
/* tax, rounded to two decimal places. The cost and percent of the */
/* tax (expressed as a decimal number) are passed to the program */
/* when you run it. */
/*********************************************************************/
PARSE ARG cost percent_tax
total = cost + (cost * percent_tax) /* Add tax to cost. */
price = ((total * 100 + .5) % 1) / 100 /* Round and remove extra */
/* decimal places. */
SAY 'Your total cost is £'price'.'