=========================================== Assignment #05 - incorrect looping using floating-point numbers =========================================== - Ian! D. Allen - idallen@idallen.ca - www.idallen.com Available online: Thursday February 4, 2011 Deliverables: In-lab demo to your instructor during Week 4. There is nothing to hand in. Download and compile/run the FunnyMath3.java program from the Class Notes. The program produces wrong results for very simple arithmetic. The two loops should loop the same number of times, but they don't. You can't fix this error. Don't use floating point for loop variables. Do these things: 1. The FunnyMath3.java program displays the current value of "d" each time through both loops. Modify the program to also display the previous value of "d" in front of "d" on the same line, separated by a space. Modify both loops. Since there is no previous value of "d" the first time through each loop, don't print the previous value of "d" on the first iteration of each loop. Example modified output: Add 0.1 from 0.1 to 0.5 0.1 0.1 0.2 [...etc...] 2. Modify the program to display the value of "d" after each loop ends. (Modify both loops.) 3. Call over your instructor and show your modified program and its output. Explain what is happening to produce these wrong answers. BONUS: Analyze the file text.bin in the Data Files section of the Course Notes. Display the file in hexadecimal and show your instructor which line-end characters are used to end each of the five lines in that text file. You may use the DEBUG hex dump program (in a DOS window) or you can download a free hex editor program (e.g. XVI32 from www.chmaas.handshake.de or "hexedit" from www.physics.ohio-state.edu) and use it to identify the line-end characters. References: 120_CharacterEncoding.html Character Encoding / Line Ends 200_DEBUGbasics.html MS-DOS DEBUG Basics for Fixed-Format Files 200_DEBUGhelp.txt Using DOS DEBUG This lab is an in-lab demo. There is nothing to hand in. -- | Ian! D. Allen - idallen@idallen.ca - Ottawa, Ontario, Canada | Home Page: http://idallen.com/ Contact Improv: http://contactimprov.ca/ | College professor (Free/Libre GNU+Linux) at: http://teaching.idallen.com/ | Defend digital freedom: http://eff.org/ and have fun: http://fools.ca/