Re: Java exercise

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ebrimagillen
    New Member
    • Oct 2006
    • 4

    #1

    Re: Java exercise

    Hello mates,
    Just needed a solution on the exercise below.



    A classic problem in introductory programming is the grains of rice on a chess board problem.
    Your program should calculate the number of rice grains on the last square of a 64 square chess board given that there is 1 grain of rice on the first square, 2 on the second square, 4 on the third square and so on.
    Use a while loop to double the number of rice grains and output the number of grains on the last square. Additionally output the total number of grains.
    Check your answer, is it sensible? If not amend your data types.
Working...