Question: Once again, use the BaseGemPrices.txt file from the practice problem above. As before, you can see that each column is of fixed width. this time,

Once again, use the BaseGemPrices.txt file from the practice problem above. As before, you can see that each column is of fixed width.

this time, instead of reading each line in the file into a single character array, you will read each line into three arrays. Read in the numbers in the first column into an integer array, the gem types in the second column into an array of strings, and the numbers in the third column into a real array.

Note: For example, the declaration for an array of 8 strings that might each be 40 characters long might look like character (len=40) :: StrArray(8)

Print a two column table to the console. The table will have the gem types and the cost per gem in each row. The cost per gem is simply the cost from the 3 column of the file table divided by the number of gems in the first column. Show 1 digit to the right of the decimal place.

Prompt the user for an output file name and store it in a string variable.

Open an output file for writing, using the entered output file name string as the file name.

Write the table you printed to the console above to the output file.

Close the output file.

You can check the output file by opening it in

Eclipse

or another decent text editor like

Notepad++.(Using the default Windows Notepad may show all of the numbers on one line.)

file: BaseGemPrices.txt

Base Gem Prices

Number Gem Cost

x10 Greenstone 24GP

x8 Malachite 22GP

x10 Fire Agate 35GP

x10 Phenalope 70GP

x10 Aventurine 70GP

x10 Amethyst 140GP

x10 Fluorspar 175GP

x10 Garnet 420GP

x10 Alexandrite 507GP

x6 Topaz 525GP

x1 Sapphire 350GP

x1 Fire Opal 525GP

x1 Diamond 700GP

x1 Ruby 1050GP

x1 Emerald 1400GP

x1 Rogue Stone 1750GP

x1 Black Pearl 3500GP

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!