Levels Tought:
Elementary,Middle School,High School,College,University,PHD
Teaching Since: | Apr 2017 |
Last Sign in: | 9 Weeks Ago, 4 Days Ago |
Questions Answered: | 4870 |
Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Hi,
I need help with my code for CIS 355A class. I am writing a code in JAVA that will convert money between the following currencies: US Dollar, Yen, and Euro. Below is the instructions of how to format the code.
STEP 2: CurrencyConversion (20 points)
You must create a program named CurrencyConversion.java that converts money between the following currencies.
Â
Given one of the three currencies (US Dollar, Yen, Euro), the program should convert the input amount into one of the other currencies. For example, if you input one (1) U.S. dollar, and you decide to convert that one dollar to a Euro, then the output should be .90.
Â
This chart provides the codes to be used as input (JPY, EURO, USD) and the conversion factors. Â
Â
CURRENCYÂ CURRENCY CODEÂ YENÂ EUROÂ USD
US Dollar
USD $1 = 123.14 $1 = .90 Euro ------------
Yen
YEN ------------- 1 Yen = .0073 Euro 1 Yen = $.0081
Euro
EURO 1 Euro = 136.08 Yen ------------
1 Euro = $1.11
Note that Step 2 DOES NOT HAVE TO USE OOP. Â Keep it simple.Â
Note that you CANNOT test for equality between strings using ==. Â Â
String color = "red";Â
THIS WILL NOT WORK: Â Â
if (color == "red")Â
YOU MUST USEÂ
if (color.equals("red")Â
Using the JOptionPane GUI, do the following.
Prompt the user for the currency code type.
Prompt the user for the amount of that currency.
Prompt the user for the currency code that the entered amount must be converted to.
Using the table above, the following formula was used to convert USD to EURO.
100.00 USD * .9 = 90.00 EURO
Display the results in a JOptionPane message box.
 1 |
Must contain program's name, student name, and description of the program |
 4 |
Documents design process and testing |
 5 |
Use JOptionPane for input and output |
 7 |
Uses logic and correct formula to compute results |
 3 |
Gives error message, allows correction of invalid data |
 20 |
 |
Â
This what I have done so far:
public class CurrencyConversionÂ
{
   public static void main(String[] args)Â
   {
      // declare variables
      double amount;
      double USDollar;
      double Yen = 0;
      double Euro;
     Â
      //prompt the user for the currency code type
      String currency = JOptionPane.showInputDialog("Enter currency code type: ");
      String message = String.format("Currency Code: ", currency);
     Â
      //prompt the user for the amount of that currency
      String aString = JOptionPane.showInputDialog("Enter amount of that currency: ");
      amount = Double.parseDouble(aString);
           Â
      //prompt the user for the currency code that the entered amount must be converted to
      String convert = JOptionPane.showInputDialog("Enter the currency code you want to convert for the amount: ");
      String text = String.format("Currency Code: ", convert);
     Â
      if(convert.equals("US Dollar"))
      {
         USDollar = 0.0081 * amount;
      }
     Â
      elseÂ
         if (convert.equals("US Dollar"))
      {
         USDollar = 1.11 * amount;
      }
     Â
     Â
      NumberFormat nf = NumberFormat.getCurrencyInstance();
           Â
      //Display the results =
      JOptionPane.showMessageDialog(null, message + currency+ " "+ nf.format(amount));   Â
      JOptionPane.showMessageDialog(null, text + convert);
   }
}
I am have trouble figuring out how to output the amount that was converted from one currency to the other currency.