Question
Write a program that will do the following. It should start by asking how many Euros a dollar will buy and reading that number. Then
Write a program that will do the following. It should start by asking how many Euros a dollar will buy and reading that number. Then it should ask how many Pound Sterling a dollar will buy and read that number. Finally, it will ask how many Yen a dollar will buy and read that number. These numbers will be read once and stored for all of the currency conversions the program performs.
Next, the program will use a loop to let the user calculate how much various amounts of dollars are worth in other currencies. For each cycle of the loop, the program will ask the user to enter the number of dollars. Then the program will ask the user to enter E to buy Euros, P to buy Pounds, or Y to buy Yen. The program will then call a method to calculate the amount of currency that will be purchased. It will pass the number of dollars and the exchange rate for that currency. Note that in each case the amount of currency exchanged will be reduced by 5% for amounts using more than $100 and 10% for amounts using $100 or less. That is, if someone wants to buy $1000 worth of some currency the program will deduct $50 from that and buy $950 worth of the other currency (we charge for the exchange services).
At the end of each conversion after the result has been displayed, the program will ask the user if there are more conversions to perform. If the user types yes, then the program continues. If the user types no, the program terminates. If the user types anything else, the program asks the user to enter yes to continue converting dollars into other currencies or no to stop and keeps looping until one of these inputs is entered. The comparison should not be case sensitive.
Note that there is only one conversion method. It is passed different parameters depending on what type or currency it is converting into. The conversion routine will compare amount in dollars with 100 and if the dollar amount is less than or equal to 100 it will reduce the dollar amount to 90% of what it was. Otherwise, it will reduce the dollar amount to 95% of what it was. In either case, it will multiply the new dollar amount by the exchange rate and return the product of this multiply.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started