- Coal Ores Can Be Squished Together To Form Coal Blocks Crafting Coal Blocks Can Be Broken Down Back To Coal Ores A Coa 1 (72.78 KiB) Viewed 99 times
Coal ores can be squished together to form coal blocks. Crafting Coal blocks can be broken down back to coal ores. A coa
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Coal ores can be squished together to form coal blocks. Crafting Coal blocks can be broken down back to coal ores. A coa
Coal ores can be squished together to form coal blocks. Crafting Coal blocks can be broken down back to coal ores. A coal block is equivalent to 9 coal ores. Both processes are done in the crafting table. Write a C++ program to model crafting with coal. 1. Declare the function void craftCoal(int& coalOres, int& coalBlocks) which: a. Takes the number of coal ores as well as coal blocks b. If the number of coal ores is less than 9, then function should break the coal blocks down to ores and add it to the number of coal ores. c. Else, the function should try to convert as many of the coal ores to blocks as possible. A block can only be crafted with exactly 9 ores. 2. In the main, ask the user how many coal blocks and ores they have in their inventory, then call craftCoal. Print the updated number of coal ores and blocks. Sample output: K Microsoft Visual Studio Debug Console How many do you have of the following? coal ores: 70 Coal blocks: 6 Crafting... You now have 7 Coal Ores and 13 Coal Blocks K Microsoft Visual Studio Debug Console How many do you have of the following? Coal ores: 8 Coal blocks: 16 Crafting... You now have 152 Coal Ores and Coal Blocks