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. Setting up the array of strings may be tricky. You may want to do this using a cell array. You may also want to set up a rank 2 array, with each string being a row of the array. You may assume that no gem type name is over 16 characters long. 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 3rd 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

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!