Wikipedia:Reference desk/Archives/Computing/2020 July 27

= July 27 =

Java!
Hi guys, can you help me figure out how could the first line of the output was correct and the others were not? Thank you! Deep humility (talk) 19:06, 27 July 2020 (UTC)

Output:

1 inch is 0.083333336 feet or 0.02540005 meters.

2 inches equal 0.33333334 feet or 0.1016002 meters.

3 inches equal 0.75 feet or 0.22860046 meters.

4 inches equal 1.3333334 feet or 0.4064008 meters.

5 inches equal 2.0833333 feet or 0.63500124 meters.


 * What is "n"? Why are you incrementing both inch and n? -- Finlay McWalter··–·Talk 19:17, 27 July 2020 (UTC)

-

Solved:

What a careless mistake! I ignored that  is incremental due to. 😳😳😵😵😬😬😱😱 Deep humility (talk) 19:19, 27 July 2020 (UTC)

User:Finlay McWalter, I modified my code a bit and the output appeared to be correct now. Thank you for your attention and enlightenment! Deep humility (talk) 19:21, 27 July 2020 (UTC)


 * Nitpicking: one meter is not 39.37 inches. Instead, one inch is defined to be exactly 0.0254 meters and one foot is exactly 0.3048 meters. 93.142.89.209 (talk) 22:02, 27 July 2020 (UTC)


 * To be fair, 1 m was exactly 39.37 inches in the US... until 1959 when the inch was redefined. See Foot (unit). --174.89.49.204 (talk) 22:42, 27 July 2020 (UTC)


 * Indeed it was. One learns something new every day! 93.142.89.209 (talk) 04:25, 28 July 2020 (UTC)


 * Oh! Thanks for the information. I was just using my reference e-book's tip! Deep humility (talk) 15:42, 28 July 2020 (UTC)


 * Your code is correct now, but note also that you don't need the variables  and   for anything.  J I P  &#124; Talk 10:36, 28 July 2020 (UTC)
 * Ahh, yes, you are right. Thank you! Deep humility (talk) 15:42, 28 July 2020 (UTC)