You have decided to dabble in the foreign currency market, and to assist your investing, you are going to code a Currency Calculator that computes the current value of each type of currency you are planning to buy.

Part A:

At present, you have decided only to trade in the following currencies: GBP (British Pounds), EUR (Common Market Euros), and JPY (Japanese Yen). When it starts, your program will ask for the current exchange rates, after which it will begin a valuation loop that lets you select the currency type and then enter the amount of that currency, whereupon the program tells you how much that would be in US dollars. A sample run would look like this (items in bold are user inputs):

Welcome to the currency calculator!

Please enter the currency rate Per US $ of the following currencies:

EUR: 1.3238
GBP: 1.52512
JPY: .0105946

Select currency for valuation (1=EUR, 2=GBP, 3=JPY, 0=Quit): 2
How many Pounds Sterling are you buying? 100

That will have a value of $ 152.51.

Currency for valuation (1=EUR, 2=GBP, 3=JPY, 0=Quit): 3
How many Yen are you buying? 15000

That will have a current value of $ 158.90

Currency for valuation (1=EUR, 2=GBP, 3=JPY, 0=Quit): 1
How many Euros are you buying? 250

That will have a current value of $ 330.95

Currency for valuation (1=EUR, 2=GBP, 3=JPY, 0=Quit): 0

Thanks for using the currency calculator!

The currency valuation is a simple multiplication of the units entered times the rate (entered at the beginning of the program). In the above program, after input of the currency rates, you may loop any number of times asking for currency type and amount, and the user does not have to select the currencies in any particular order (and can re-select a currency any number of times).

Also note that when the program asks for the quantity of the currency, it uses the correct name (e.g., Pounds Sterling, Yen, etc.). The bold and italics, however, are not required that is just shown above for emphasis.

Part B:

After completing the program according to the Part A specifications, you will then modify its operation as follows:

1)Add two additional currencies to be purchased: Canadian dollars (CAD) and Russian Rubles (RUB).

2)The Valuation loop should include an option #9: to change the stored exchange rates for all the currencies

3)The program should accumulate the total valuation of all proposed currency purchases in the session and print that amount after the operator chooses to quit the valuation loop.

A sample run for after completing Part B would look like this (items in bold are user inputs):

Welcome to the currency calculator!

Please enter the currency rate Per US $ of the following currencies:

EUR: 1.3238
GBP: 1.52512
JPY: .0105946
CAD: .98629
RUB: .033286

Select currency for valuation (1=EUR, 2=GBP, 3=JPY, 4=CAD, 5=RUB, 9=New Rates, 0=Quit): 2
How many Pounds Sterling are you buying? 100

That will have a value of $ 152.51.

Select currency for valuation (1=EUR, 2=GBP, 3=JPY, 4=CAD, 5=RUB, 9=New Rates, 0=Quit): 3
How many Yen are you buying? 15000

That will have a current value of $ 158.90

Select currency for valuation (1=EUR, 2=GBP, 3=JPY, 4=CAD, 5=RUB, 9=New Rates, 0=Quit): 1
How many Euros are you buying? 250

That will have a current value of $ 330.95

Select currency for valuation (1=EUR, 2=GBP, 3=JPY, 4=CAD, 5=RUB, 9=New Rates, 0=Quit): 4
How many Canadian dollars are you buying? 200

That will have a current value of $ 197.26

Select currency for valuation (1=EUR, 2=GBP, 3=JPY, 4=CAD, 5=RUB, 9=New Rates, 0=Quit): 5
How many Russian Rubles are you buying? 10000

That will have a current value of $ 332.86

Select currency for valuation (1=EUR, 2=GBP, 3=JPY, 4=CAD, 5=RUB, 9=New Rates, 0=Quit): 9
Currency (1=CAD, 2=GBP, 3=EUR, 4=JPY, 5=RUB, 9=New Rates, 0=Quit): 9

Please enter the currency rate Per US $ of the following currencies:

EUR: 1.344
GBP: 1.545
JPY: .01205
CAD: .9952
RUB: .0303

Select currency for valuation (1=EUR, 2=GBP, 3=JPY, 4=CAD, 5=RUB, 9=New Rates, 0=Quit): 5
How many Russian Rubles are you buying? 5000

That will have a current value of $ 151.50

Select currency for valuation (1=EUR, 2=GBP, 3=JPY, 4=CAD, 5=RUB, 9=New Rates, 0=Quit): 0

The total value of the proposed currency purchases was: $1,323.98

Thanks for using the currency calculator!

Note that in producing the final currency purchase value you do not recalculate earlier currency selections if the rate was changed during the session just accumulate all the previously calculated current value amounts.

To receive full credit on this program you must use the following techniques within the code:

-Appropriate use of global and local variables

-A separate method call to obtain the currency rate values

-A separate method call to handle the input/valuation loop

-Proper currency formatting of the calculated US $ valuation amount

In other words, you wish to minimize the amount of code in the Main method and put as much as possible (without duplicating code) into methods which are called from Main.

Part C:

Now modify the final valuation printout (the total amount shown after the user quits the valuation loop) to show each currency separately; you should show both the total number of units to be purchased and the total value for each currency. Note, however, that if the currency rates are changed during the running of the program, you should not re-calculate totals based on revised rates just display the sums for the amounts at the time the user valued them. So, for example, the session above would have a final output of:

EUR: 250 units costing $330.95
GBP: 100 units costing $152.51
JPY: 15000 units costing $158.90
CAD: 200 units costing $197.26
RUB: 15000 units costing $484.36

Thus the total value of the proposed currency purchases was: $1,323.98

For this assignment you need only submit your final version of the program; you do not need to submit separate Parts (A,B,C). Submit a zipped version of your full netbeans project through blackboards assignment tab.

Part D:

Make the program more efficient and clean by reducing duplicated code; in other words, minimize the amount of code in each case block (code can be reduced to just a couple of lines of code in each case option).

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be 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 complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.