*****************************************
* CobolScript program name: arithmetic.cbl
* This program provides examples
* of arithmetic statement usage.
*
* Copyright 2000 Deskware, Inc.
*****************************************
1 counter pic -----.99.
1 old_counter pic -----.99.
1 rmain pic 9999.99.
move zero to counter.
perform compute_stats.
goback.
compute_stats.
move 1.25 to counter.
move counter to old_counter.
add 1 15.5 to counter giving counter.
display ` 1 + 15.5 + ` & old_counter & ` =`&
counter.
move counter to old_counter.
add 15.5 to counter rounded.
display ` 15.5 +` &old_counter& ` (result rounded) =`&counter.
move counter to old_counter..
subtract 15.5 from counter giving counter rounded.
display old_counter & ` - 15.5 (result rounded) =` & counter.
move counter to old_counter..
subtract 15.5 from counter.
display old_counter & ` - 15.5 =` & counter.
move counter to old_counter.
multiply 2.2 by counter giving counter rounded.
display old_counter & ` * 2.2 (result rounded) =` & counter.
move counter to old_counter.
multiply 1.2 by counter.
display old_counter & ` * 1.2 =` & counter.
move counter to old_counter.
divide 1.5 into counter giving counter.
display old_counter & ` / 1.5 =` & counter.
move counter to old_counter.
divide counter by 1.5 giving counter rounded.
display old_counter & ` / 1.5 (result rounded) =` & counter.
move counter to old_counter.
divide 1.2 into counter rounded.
display old_counter & ` / 1.2 (result rounded) =` & counter.
move counter to old_counter.
divide 2 into counter giving counter remainder rmain.
display old_counter &` / 2 =`&counter&`, remainder = `&rmain.
move counter to old_counter.
divide counter by 2 giving counter remainder rmain.
display old_counter&` / 2 =`&counter&`, remainder = `&rmain.