Question: Java program A variation on the Indian legend goes that the tradition of serving Paal Paysam to visiting pilgrims started after a game of chess

Java program

A variation on the Indian legend goes that the tradition of serving Paal Paysam to visiting pilgrims started after a game of chess between the local king and the lord Krishna himself.

The king was a big chess enthusiast and had the habit of challenging wise visitors to a game of chess. One day a traveling sage was challenged by the king. To motivate his opponent the king offered any reward that the sage could name. The sage modestly asked just for a few grains of rice in the following manner: the king was to give the sage a single grain of rice on the first day of the next month. On the second day the king would give the sage two grains of rice on the following day, and four grains of rice the 3rd day. Each day doubling the amount of rice.

If the next month had 30 days in it. Make a for loop that shows the amount of rice each day, and then gives the final amount of rice given all together. Make sure to write a summary at the end.

Sample output:

Day # 1 - Rice count = 1 - Total Rice count = 1 Day # 2 - Rice count = 2 - Total Rice count = 3 Day # 3 - Rice count = 4 - Total Rice count = 7 Day # 4 - Rice count = 8 - Total Rice count = 15

...

Day # 30 - Rice count = ? - Total Rice count = ?

Total Rice was = ?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!