Question: You have recently been hired by Microsoft to write a program that calculates the distance between two blocks in the popular Minecraft game. For those
You have recently been hired by Microsoft to write a program that calculates the distance between two blocks in the popular "Minecraft" game. For those of you who haven't played it, Minecraft is a game in which players explore a vast 3D world that is made up of cubes.
A block in Minecraft can be oriented in the game using a 3D point denoted as (x,y,z). Your program will prompt the user to enter in two points of two separate blocks and then determine how far away these blocks are. Here's how your program should work:
- Ask the user for Block #1's x component
- Ask the user for Block #1's y component
- Ask the user for Block #1's z component
- Ask the user for Block #2's x component
- Ask the user for Block #2's y component
- Ask the user for Block #2's z component
- Compute x, y and z distance between the two blocks (hint: use the abs function to compute the absolute value of an expression, if necessary)
- Compute the straight-line distance between the two blocks formatted to two decimal places. Hint: you can compute the square root of a number by raising it to the 0.5 power.
Here is a copy of the 3D distance formula in case you haven't taken geometry in a while:

Below are a few sample runnings of your program:
Minecraft block distance calculator Block #1 x: 0 Block #1 y: 0 Block #1 z: 0 Block #2 x: 10 Block #2 y: 0 Block #2 z: 0 X distance: 10 Y distance: 0 Z distance: 0 Straight line distance: 10.00
Minecraft block distance calculator Block #1 x: 5 Block #1 y: 5 Block #1 z: 0 Block #2 x: 10 Block #2 y: 10 Block #2 z: 5 X distance: 5 Y distance: 5 Z distance: 5 Straight line distance: 8.66
Minecraft block distance calculator Block #1 x: 50 Block #1 y: -3 Block #1 z: 12 Block #2 x: 99 Block #2 y: 82 Block #2 z: -16 X distance: 49 Y distance: 85 Z distance: 28 Straight line distance: 102.03
Comment your source code and describe your code to someone who may be viewing it for the first time.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
