Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a java program. An elastic rope starts out with length 100 meters. The sta

ID: 3645698 • Letter: W

Question

Write a java program.

An elastic rope starts out with length 100 meters. The start of the rope is fixed to a pole and a worm is placed on the rope at the start and the worm starts crawling towards the end. Each day the worm crawls 6 meters along the rope. Each day the rope is stretched by 100 meters. After how many days does the worm reach the end of the rope?

Sample Output:
Day = 0 Million. Distance from end = 0 Million meters.
Day = 1 Million. Distance from end = 19 Million meters.
Day = 2 Million. Distance from end = 30 Million meters.
Day = 3 Million. Distance from end = 39 Million meters.
Day = 4 Million. Distance from end = 45 Million meters.
Day = 5 Million. Distance from end = 49 Million meters.

Explanation / Answer

void worm() { long rope = 100; // length of rope 100 mts initially long wormSpeed = 6; // Speed of worm-6mts long wormPos = 0; long stretch = 100; // Rope is Stretched at the rate of 100 mts/day // After how many days does the worm reach the end of the rope? // BUT the ant's distance has stretched also, which makes the rope at 300m long day = 0; while(day=rope) { break; } day++; } if (wormPos>=rope) { System.out.println("Escaped Day " + day + ", Worm at " + wormPos); } else { System.out.println("Worm gave up."); } }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote