After walking for 2 days, 7 hours, 27 minutes and about 36 seconds, Don Ramon and el chavo finally made it to Acapulco. Needless to say that they are excited and want to explore the city and buy food and souvenirs.

Unfortunately, things are not quite as straightforward as in Mexico city. For starters, prices are listed in foreign currencies, and for some reason stores do not list the unit price of a product. El chavo wants to buy his favorite food "torta de jamon" (ham sandwich), and while one store has the item listed as 4 tortas = 20 dollars, another one lists the same item as 5 tortas = 15 euros. Since they are already short on cash they do not want to spend more money than what they should. They could try figuring out the conversions and unit prices but as you know, they are not very good with math.

Y ahora, quin podr ayudarlos? (who can help them now?).

Your assignment

One more time, you are to play the role of el chapuln colorado. Write a program that solves this problem. The idea is to read some information from the console and calculate the exchange rate between currencies as well as the unit price of the inputted item. What makes this problem a little harder is that your program needs to be able to handle any type of currency.

To give you a better idea of what you need to do I have included (below) two sample runs of the program. Notice that the first column adjusts to the length of the words. See image. See next image.

Formatting

Your output should be formatted in 2 columns, as shown above. Keep in mind that the input currencies may be arbitrarily long and your formatting for the first column should adjust accordingly. Also, the exchange rates should be reported with exactly 2 decimal spaces.

You may assume:

  • All input exchange rates are short enough so that a width of 8 for the second column is sufficient.
  • When prompted for the desired purchase, the user will enter an integer followed by the plural of an item with no blank spaces (e.g., beach balls is entered as beach-balls).
  • When prompted for the price, the user will enter a double followed by the plural of a currency with no blank spaces (e.g., swiss francs is entered as swiss-francs).
  • The pluralization involves only adding "s" to the end of the item or currency. Valid items include "tortas" and "ducks" as well as the currencies "pesos" and "euros". Examples of invalid inputs are "feet" and "tamales" (contrary to what some of you might think, the singular form of tamales is "tamal" and not "tamale").
Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.