Question

write a Java console application that converts between currencies US Dollar ($), Euro (€), and Japanese...

write a Java console application that converts between currencies US Dollar ($), Euro (€), and Japanese Yen (¥). Prompt the user for a conversion code:

Code   Conversion   Last run input
a   US Dollar  Euro   32
b   US Dollar  Japanese Yen   64
c   Euro  US Dollar    200
d   Euro  Japanese Yen    300
e   Japanese Yen  US Dollar   24
f   Japanese Yen  Euro   28
x   Exit  

Then prompt and get from the user a currency value. Convert the currency value and show the two values, rounded to two decimal places, with appropriate units. Continue to prompt the user for conversion codes until the sentinel value of ‘x’. Research the current conversion rates, and represent and use them as double constants. Locate the UNICODE values for units € and ¥, and represent and use them as string constants. They will be in the form "\uHHHH". Use the inputs shown in the table for the last six inputs.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.Scanner;

public class CurrencyConverter {
   public static double USD2EURO=0.89;
   public static double USD2YEN=111.33;
   public static double EURO2USD=1.12;
   public static double EURO2YEN=124.51;
   public static double YEN2USD=0.0090;
   public static double YEN2EURO=0.0080;
  
   public static final String EUROSYM="\u20ac";
   public static final String YENSYM="\u00A5";
   public static final String USDSYM="$";
   public static void main(String[] args) {
       // TODO Auto-generated method stub
              
       Scanner sc=new Scanner(System.in);
       System.out.println("Code Conversion \t\t Last run input");
       System.out.println("a US Dollar  Euro\t \t 32");
       System.out.println("b US Dollar  Japanese Yen\t 64");
       System.out.println("c Euro  US Dollar\t\t 200");
       System.out.println("d Euro  Japanese Yen\t 300");
       System.out.println("e Japanese Yen  US Dollar\t 24");
       System.out.println("f Japanese Yen  Euro\t 28");
       System.out.println("x Exit");
      
       System.out.println("Press Enter!!");
       while(true){
           sc.nextLine();
           System.out.println("Enter the code of the conversion:");
           String choice=sc.nextLine();
           double value=0;
           switch (choice) {
           case "a":
               System.out.println("Enter the curreny value in dollar:");
               value=sc.nextDouble();
               System.out.println(value+" "+USDSYM+"="+value*USD2EURO+" "+EUROSYM);
               break;
           case "b":
               System.out.println("Enter the curreny value in dollar:");
               value=sc.nextDouble();
               System.out.println(value+" "+USDSYM+"="+value*USD2YEN+" "+YENSYM);
               break;
           case "c":
               System.out.println("Enter the curreny value in euro:");
               value=sc.nextDouble();
               System.out.println(value+" "+EUROSYM+"="+value*EURO2USD+" "+USDSYM);
               break;
           case "d":
               System.out.println("Enter the curreny value in euro:");
               value=sc.nextDouble();
               System.out.println(value+" "+EUROSYM+"="+value*EURO2YEN+" "+YENSYM);
               break;
           case "e":
               System.out.println("Enter the curreny value in yen:");
               value=sc.nextDouble();
               System.out.println(value+" "+YENSYM+"="+value*YEN2USD+" "+USDSYM);
               break;
           case "f":
               System.out.println("Enter the curreny value in yen:");
               value=sc.nextDouble();
               System.out.println(value+" "+YENSYM+"="+value*YEN2EURO+" "+EUROSYM);
               break;
           case "x":
               System.exit(0);
           default:
               break;
           }
       }
   }

}

Code a US Dollar Euro b US Dollar EJapanese Yen Conversion Last run input 32 64 200 300 Euro US Dollar d Euro Japanese Yen e

Add a comment
Know the answer?
Add Answer to:
write a Java console application that converts between currencies US Dollar ($), Euro (€), and Japanese...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program that will convert U.S. dollar amounts to Japanese yen and to euros, storing...

    Write a program that will convert U.S. dollar amounts to Japanese yen and to euros, storing the conversion factors in the constants YEN_PER_DOLLAR and EUROS_PER_ DOLLAR. To get the most up-to-date exchange rates, search the Internet using the term “currency exchange rate”. If you cannot find the most recent exchange rates, use the following: 1 Dollar = 98.93 Yen 1 Dollar = 0.74 Euros Format your currency amounts in fixed-point notation, with two decimal places of precision, and be sure...

  • Write a C++ console application that uses functions to calculate an employee’s salary.

    Write a C++ console application that uses functions to calculate an employee’s salary.PART 1: Create a void function to print a menu asking the user to choose from the following options:1 - Annual salary2 - Monthly salary3 - Daily rate of pay4 – ExitThe void function only prints the menu. Format your cout statement to include the menu as displayed above.If the chosen option is 1- Annual Salary, ask the user for the number of hours they work perweek and...

  • Write a Java application that prompts the user for pairs of inputs of a product number...

    Write a Java application that prompts the user for pairs of inputs of a product number (1-5), and then an integer quantity of units sold (this is two separate prompts for input values). You must use a switch statement and a sentinel-controlled loop (i.e. a loop that stops execution when an out of range value, such as -1, is input). All 15 items below are for a single purchase. There are five sets of inputs as follows: Product 1    1...

  • Click on “Currencies” and examine how exchange rates of various currencies have changed in recent three...

    Click on “Currencies” and examine how exchange rates of various currencies have changed in recent three months. In general, have most currencies strengthened or weakened against the dollar over the last three months? Offer one or more reasons to explain the recent general movements in currency values against the dollar. M Foreign Exchange Rates X CE Files \C Chegg Study | Guided so X E C O money.cnn.com/data/currencies/index.html X 6 ! ONN Money Companies Markets Tech Media UR, Q =...

  • Assignment Overview This assignment will give you more experience on the use of strings and iterations....

    Assignment Overview This assignment will give you more experience on the use of strings and iterations. The goal of this project is to use Google’s currency converter API to convert currencies in Python and display the result to user by processing the returned results. Assignment Background The acronym API stands for “Application Programming Interface”. It is usually a series of functions, methods or classes that supports the interaction of the programmer (the application developer, i.e., you) with some particular program....

  • Can someone modify my code so that I do not get this error: Exception in thread...

    Can someone modify my code so that I do not get this error: Exception in thread "main" java.lang.NullPointerException at java.awt.Container.addImpl(Container.java:1043) at java.awt.Container.add(Container.java:363) at RatePanel.<init>(RatePanel.java:64) at CurrencyConverter.main(CurrencyConverter.java:16) This code should get the amount of money in US dollars from user and then let them select which currency they are trying to convert to and then in the textfield print the amount //********************************************************************* //File name: RatePanel.java //Name: Brittany Hines //Purpose: Panel for a program that convers different currencyNamerencies to use dollars //*********************************************************************...

  • Use the following table to complete assignment Suppose that on March 1 of the current year, the peso-US$ exchange rate w...

    Use the following table to complete assignment Suppose that on March 1 of the current year, the peso-US$ exchange rate was P5/$. On March 31 of the current year, the exchange rate stood at P8/$. Calculate the 1-month percent change in the value of the Mexican peso (= P). Calculate the spot Korean won-Japanese yen exchange rate in W/¥. (Korean won = W; Japanese yen = ¥) Calculate the spot Taiwanese dollar-euro exchange rate in T$/€. (Taiwanese dollar = T$;...

  • 1. Create a new multi-class Java program which implements a vending machine simulator which contains the...

    1. Create a new multi-class Java program which implements a vending machine simulator which contains the following functionality: A) At program startup, the vending machine is loaded with a variety of products in a variety of packaging for example soda/tonic/Coke in bottles, peanuts in bags, juice in cartons, etc. Also included is the cost of each item. The program should be designed to easily load a different set of products easily (for example, from a file). Also at program startup,...

  • 1. John sold a call option on Euro for $.04 per unit. The strike price was...

    1. John sold a call option on Euro for $.04 per unit. The strike price was $1.30, and the spot rate at the time the option was exercised was $1.32. Assume John bought the Euro from the market if the option was exercised. Also assume that there are 100,000 units in a Euro option. What was John’s net profit on the call option? Baylor Bank believes the New Zealand dollar will appreciate over the next 20 days from $.50 to...

  • Write a Java program to convert octal (integer) numbers into their decimal number equivalents (exactly the...

    Write a Java program to convert octal (integer) numbers into their decimal number equivalents (exactly the opposite of what you have done in Assignment 4). Make sure that you create a new Project and Java class file for this assignment. Your file should be named “Main.java”. You can read about octal-to-decimal number conversions on wikepedia Assignment 4 is at the bottom Objective Your program should prompt the user to enter a number of no greater than 8 digits. If the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT