### A mathematical table.

No. 106

#### Nicely formatting sine values.

 Q: We are interested in the following output presenting the sine function rounded to three decimal places:  x | sin(x) ----+------ 0 | 0.000 5 | 0.087 10 | 0.174 15 | 0.259 20 | 0.342 ----+------- 25 | 0.423 30 | 0.500 35 | 0.574 40 | 0.643 ----+------- ... (left out for brevity's sake) ----+------- 325 |-0.574 330 |-0.500 335 |-0.423 340 |-0.342 ----+------- 345 |-0.259 350 |-0.174 355 |-0.087You may also generate HTML output. Write a corresponding Java application producing this output. You will have to deal with alignment problems, leading spaces, padding zeros and so on. Though more sophisticated support exists the following hints will fully suffice: Consider the sin(...) function. The documentation will tell you that the argument to sin(...) is expected to be in radians rather than common degree values from [0,360[ being expected on output. So you will have to transform degree values to radians. Depending on the angle's value you may want to add one or two leading spaces to keep the first column right aligned. Depending on the sign you may want to add leading spaces to the second column. Rounding the sine's value is the crucial part here. The function round() is quite helpful. Consider the following example rounding 23.22365 to four decimal places: Multiplication by 10000 results in 232236.5 round(232236.5) results in 232237 (long). Integer division by 10000 yields 23 The remainder (by 10000) is 2237 So you may print 23.2237 this way You'll need padding zero values to transform e.g. “0.4” to “0.400”. A: Maven module source code available at P/Sd1/rounding.