Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program in java It should start by asking how many Euros a dollar will buy and reading that number. Then it should ask

Write a program in java

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 as parameters. Note that in each case the method will do the following calculation. 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 by the main method, 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.

so far I got

public class Program7 { public static void main(String[] args) { char us_dollar_sym = 36; char pound_sym = 163; char yen_sym = 165; char euro_sym = 8364; Scanner s = new Scanner(System.in); int E1, P1, Y1; System.out.println("How much would a dollar buy in euros?"); E1=1; System.out.println (" A dollar would get you " + E1*0.734878047 + euro_sym); System.out.println("How much would a dollar buy in Pounds?"); P1=1; System.out.println (" A dollar would get you " + P1*0.621484+ pound_sym); System.out.println("How much would a dollar buy in Yen?"); Y1=1; System.out.println (" A dollar would get you " + Y1*107.174+ yen_sym); and now I'm at a total loss

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

Oracle Database Foundations Technology Fundamentals For IT Success

Authors: Bob Bryla

1st Edition

0782143725, 9780782143720

More Books

Students also viewed these Databases questions