Program 6, Mining Our Business.

Short Description:

Write a program which determines the next location where a company should establish a mining operation.

This assignment is worth 50 points. It has been constructed with Dr. Meyer, who's assistance is appreciated and acknowledged. I hope that I got into the general spirit of things.

Goals

When you finish this homework, you should have:

Formal Description

You have been hired by the Intergalactic Bureau of Mines (IBM) to produce a program to help them determine where they should build their next mine.

IBM has hired a number of prospectors, who fly through known space surveying planets. A prospector travels to a planet, inspects the resource potential and sends a report back to IBM headquarters. This report includes the planet's coordinates (as integers), an estimated value of the resources (in Denomination less Everywhere Credits or DECs) and the name of the planet. These reports are collected in a file at IBM headquarters. Your job is to process this report file and recommend which planet should next be mined.

IBM uses the following decision making process to determine the next planet to mine.

  1. Calculate the distance, in standard units, to the a planet
  2. Calculate the haul potential (HP), HP = (potential value)/(distance from headquarters).
  3. Select the planet with the highest HP.
  4. If two planet's HP are equivalent (rounded to the nearest DEC), select the closest planet.
  5. If two planets are the same after (3) and (4), select the planet encountered in the file first.
Since warp drive has not yet been invented, all distances are calculated using the standard Euclidean distance formula. All coordinates are given in standard units.

Unfortunately, for you at least, IBM's prospectors are from different planets. Many use different number systems and the report contains the raw data, so you will need to deal with this minor problem. (IBM deals with the miner problems.) No IBM scout uses a data format with less than 2 digits, or more than 16, so you must be able to deal with a number in any base between 2 and 16 inclusive. All prospectors use the standard digits: 0-9 and A-F for 10-15.

The data file is in the following format. Each prospector's report is contained in three lines.

  1. The coordinates of the planet, a triple of integers in the base, between 2 and 16, used by the prospector. These numbers are inside of parenthesis and separated by commas.
  2. The estimated worth of the planet, also in the arbitrary base used by the prospector, followed by a comma and the name of the planet.
  3. A single integer, supplied by IBM which is the base that the prospector used.
There are many reports in the file, and all must be processed. For example the file might contain the following:
(4150,504C,4500)
3F2C, The Land of Waz
16
(0101101110,11101001,1111100011)
11100101101, A Bit too Far
2
(34,12,100)
4652, Trilobyte Major
7

All distances should be calculated from IBM headquarters. These are currently at (6,16,1911) base 10. For tax purposes, however, IBM occasionally moves their headquarters. While your programs should not require the headquarters to be entered, these values should be easy to change in the future when IBM relocates.

Your program should begin by asking for the name of the file to be processed. Additionally, it should ask if it is to operate in verbose or silent mode. If the user selects silent mode, only the name of the ONE planet, along with the coordinates, distance, HP should be printed. In verbose mode, this information should be printed for EVERY planet in addition to the final result detailed above.

So verbose output from the above input files should be:

Please enter the file name: testfile1.dat
Do you wish to operate in verbose mode (Y/N): y
Processing testfile1.dat:

The Land of Waz, (16720,20556,17664) 30812.4 0.52
A Bit too Far, (366, 233, 995) 1007.8 1.82
Trilobyte Major, (25,9,49) 1862.1 0.91

IBM should mine:
A Bit too Far, (366, 233, 995) 1007.8 1.82
In silent mode, only the last two lines should be printed. Please note, your output is expected to match the format of the above example.

Discussion

You should make appropriate use of constants and variables.

Your identifiers should be constructed properly, with meaningful names.

You should document your code with comments.

Your program should be fully interactive and provide the user with instructions.

Your output should be organized, easy to read, and make appropriate use of white space.

You should employ functions to simplify your code.

Your functions should demonstrate functional cohesion.

Most functions should be of reasonable length (~20 lines).

The case of input should not matter. Your program should be able to deal with responses in any case.

Required Files

A single source code file.

Submission

Email your final source code file to danbennett360@gmail.com.