Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are to write a program to be used at a currency exchange. The exchange converts to and from: US Dollars Euros Yen Yuan British

You are to write a program to be used at a currency exchange. The exchange converts to and from:

US Dollars

Euros

Yen

Yuan

British Pounds

Each transaction is charged a %5 percent exchange fee.

Your code should:

1.Input the currency they have using a menu

2.Input the amount of that currency they wish to exchange

a.Use a method that uses a try-catch

3.Input the currency they wish to exchange to

4.Calculate the fee and deduct from the original amount

5.Convert the deducted amount to the new currency

6.Output (with labels):

a.The original amount

b.The fee

c.The amount received

Allow this to be repeated as the user wishes

Current exchange rates:

1 US Dollar -> 0.842815 Euros

1 US Dollar -> 111.779407 Yen

1 US Dollar -> 6.609776 Yuan

1 US Dollar -> 0.744047 Pounds

Requirements:

Use a generic menu and conversion method

o Your conversion method will convert to dollars, and then to the desired currency

Use declared constants for the four exchange rates, and the fee rate (5%)

o No exchange rate needed for dollars

Output rounded to 2 decimals

You should do the usual design work, including test data, but no need to turn it in.

Add the following summary data:

The number of exchanges

o Do not count the times they entered the same currency

The change in value for each currency

o Start all 5 accumulators out at 0.0

o Add the total amount of the currency received to the proper accumulator

o Subtract the amount of currency given out to the proper accumulator

o Some accumulators may end up negative

o Example: 100 dollars is received. The fee would be 5, so 95 dollars is exchanged to 70.68 pounds

The dollar accumulator is increased 100, the pound decreased 70.68

The overall change in value of all currency amounts, in dollars

o Use the 5 accumulators to determine the value, in dollars, of all monies

o Start with the change in dollars, and add to that the converted changes of the other four currencies.

Files:

Keep a log file of all transactions. One line per transaction. Example:

Dollars in: 100.00 fee: 5.00 Yuan out: 627.93

Pounds in: 400.00 fee: 20.00 Euros out: 430.44

Yuan in: 4500.00 fee: 225.00 Yen out: 72295.49

Instead of setting the exchange rates in constants, make them variables and before you start transactions read these rates from a file. The file should be called rates.txt and have the four exchange rates, Euro, Yen, Yuan, and Pounds in that order. (This is so the company can send out updated rates daily)

Suggestions:

You will end up with 5 cases in the outside switch, and 5 in each of those cases. Check your work thoroughly to be sure you have it all working well.

O One case in each will be: "Same currency, no exchange done" if they choose to convert to the same currency they have.

Start with three currencies and get it to work. Then add the forth and test. Then add the fifth and test.

You may find the following handy (I sure did)

o A method that takes a single char as a parameter and returns a string

Send it A through E, and it returns the name of the currency

o A single output method

Send it the two chars (A through E) that represent the currencies, the original amount, the fee, and the resultant currency amount

Saves having to write 20 different output sections

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Horse Betting The Road To Absolute Horse Racing 2

Authors: NAKAGAWA,YUKIO

1st Edition

B0CFZN219G, 979-8856410593

More Books

Students also viewed these Databases questions