Lesson 18. Capstone project: A program - Who drank the most beer?
18.1 Your mission
The Capstone Project for this Unit is very similar to the Capstone project of Unit 3. The only difference is that in the current Capstone Project, you are required to write a Clojure program that runs from the command line, while in Unit 3, you were required to write some functions that run in the REPL. Feel free to use the code you wrote as a solution to the Capstone Project of Unit 3 or the code we suggested as a solution.
Here are the requirements for the current Capstone Project:
An American, a Brit and a Frenchman are sitting at a pub. After a couple of hours, each of them starts to brag about the amount of beer he drank:
The American says: "I drank x 20 ounce cans"
The Brit replies: "I drank y pints"
The Frenchman concludes: "I drank z demis"
The question is: which one of them drank the most?
A few facts about units of beers:
- A 20 ounce can is: 591 milliliters
- A pint is: 473 milliliters
- A demi is: 500 milliliters
Your mission to write a Clojure program named my-beers that receive 4 arguments:
- The first argument is the program mode
- The second argument is the number of cans the American drank
- The third argument is the number of pints the Brit drank
- The fourth argument is the number of demis the Frenchman drank
The program handles two modes that is controlled by the first argument: