Khufu has built a 100 cubit long track, with regular distances marked off in cubits, palms and fingers, along which Nebi and Ako must pull a large stone. Their punishment ends when they have pulled the stone the entire distance of the track. Their daily food, however, depends on their progress for a given day.
Khufu has decreed that Nebi and Ako will receive one grain of rice for each finger's distance they pull the stone on a given day. So if they manage to pull the stone 10 cubits, or 240 fingers, they will receive a total of 240 grains of rice.
You have been assigned the tasks of computing the amount of rice that Nebi and Ako are given each day. Each morning and afternoon you record the position of the stone in cubits, palms and fingers. Since Nebi and Ako will never pull the stone backwards, you know that the ending position will be at least as large as the starting position.
Not wishing to anger the great Khufu with inaccurate computations, you have decided to write a program which will accurately compute the amount of rice given to Nebi and Ako each day. Your program should:
Since you occasionally have one of your assistants take the readings for you, and your assistants are not the swiftest ship on the Nile, you want your program to accept input which is not in proper form. Therefor input like 0 cubits 0 palms and 35 fingers should not cause an error in your computation, however you should output 1 cubit, 2 palms and 3 fingers.
Your program should produce output similar to the following:
Enter the starting cubits => 0 Enter the starting palms => 0 Enter the starting fingers => 0 Enter the ending cubits => 0 Enter the ending palms => 0 Enter the ending fingers => 35 Nebi and Ako started at: 0 cubits 0 palms 0 fingers ended at: 1 cubits 2 palms 3 fingers Distance Traveled : 1 cubits 2 palms 3 fingers Total Rice: 35 grains.
Just a note 1 cubit = 6 palms and 1 palm = 4 fingers. This never changes. Khufu however, may want to use this program in the future, and he may give more than one grain of rice for each finger traveled, so it should be easy to MODIFY your program to accomplish this. You have decided that you don't want to input this value each time you run the program, so it should be part of your code.
Be cautioned, Nebi and Ako would really like to add your assistance to the task of pulling the stone, so they may, for example, try to make the computation difficult. For example they begin the day at 23 cubits, 5 palms and 3 fingers, and stop at 24 cubits, 0 palms and 0 fingers, just to try to goof up your computations. Telling the Great Khufu that they have moved 1 cubit -1 palms and -1 fingers is likely to have you pulling a rope next Nebi and Ako. Unless you want end up with 1/3 of a grain of rice for each finger you pull the stone, make sure you test all possible cases.