Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7615797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:43:55+00:00 2026-05-31T02:43:55+00:00

Currency Exchange Class: Develop a class currency which converts US dollars to values from

  • 0

Currency Exchange Class:

Develop a class currency which converts US dollars to values from 5 countries of your choice. Current exchange rates can be found at http://www.fms.treas.gov/intn.html#rates. The class should define constants for the exchange rates and a private dollar field. Methods might include utilities such as toEuros, toPesos, etc which return the dollar field in the corresponding currency.

Client Application:

Develop a Java application to convert dollars to the desired currency. The end-user should supply the dollar amount and indicate which currency to convert to. The client application should call the appropriate method to obtain the equivalence in the desired currency. Display the dollar amount and it’s equivalent on the monitor. You may use either the Scanner or JOptionPane class for obtaining user input. A sample run using the Scanner class is shown below:

Enter a dollar amount: 5:00

Enter the currency to convert to

(1) euro, (2) pound, (3) taka, (4) yen, (5) rupees :

5.0 dollars = 3.845 euros

You may use any method to indicate the desired currency. However, instructions must be clear to the end-user.

This is my service class

public class CurrencyExchange
{
   private double dollar;
    private double euro, pound, taka, yen, rupees;
    private double currency;

    private static final double EURO = 0.7650;
    private static final double POUND = 0.6370;
    private static final double TAKA = 79.0000;
    private static final double YEN = 78.0000;
    private static final double RUPEES = 52.2500;

    public CurrencyExchange()
    {
       dollar = 0;
    }

    public CurrencyExchange(double dollars)
    {
       dollar = dollars; 
    }

    public void setEuro (double dollars)
    {
       euro = dollars * EURO;
    }

    public double getEuro()
    {
       return euro;
    }

    public void setPound (double dollars)
    {
       pound = dollars * POUND;
    }

    public double getPound()
    {
       return pound;
    }

    public void setTaka (double dollars)
    {
       taka = dollars * TAKA;
    }

    public double getTaka()
    {
       return taka;
    }

    public void setYen  (double dollars)
    {
       yen = dollars * YEN;
    }

    public double getYen()
    {
       return yen;
    }

    public void setRupees (double dollars)
    {
       rupees = dollars * RUPEES;
    }

    public double getRupees()
    {
       return rupees;
    }

    public double getCurrency()
    {
       return currency;
    }

}

This is my client class

import java.util.Scanner;

public class CurrencyExchangeClient
{
   public static void main(String[] args)
    {
       Scanner in = new Scanner(System.in);


        System.out.print("Enter a dollar amount: ");
        double dollars = in.nextDouble();

        System.out.println("Enter the currency to convert to (1) euro, (2) pound, (3) taka, (4) yen, (5) rupees : ");
        int response = scan.nextInt;


        if (response == 1 || response == 2 || response == 3  || response == 4 || response == 5)
        dollars = scan.nextDouble();

        switch (response)
        {
           case 1: getEuro();
                    break;
            case 2: getPound();
                    break;
            case 3: getTaka();
                    break;
            case 4: getYen();
                    break;
            case 5: getRupees();
                    break;
            default: System.out.println("Invalid Response");
        }

        System.out.println(getCurrency());



    }
}

Whenever I compile the program using JGrasp it keeps giving me a missing symbols error, I don’t know why though. It should look like the Example application program.

In addition are the toEuro (method) needed and do I have to remove the constants in private class and just set them up in accessor/mutator methods instead if that helps with the program.

CurrencyExchangeClient.java:14: error: cannot find symbol
        int response = scan.nextInt;
                       ^
  symbol:   variable scan
  location: class CurrencyExchangeClient

CurrencyExchangeClient.java:30: error: cannot find symbol
            case 5: getRupees();
                    ^
  symbol:   method getRupees()
  location: class CurrencyExchangeClient

Those are just a couple of examples.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T02:43:56+00:00Added an answer on May 31, 2026 at 2:43 am

    Syntax errors and logical errors are there.

    You should do like this…

    import java.util.Scanner;
    
    public class CurrencyExchangeClient
    {
       public static void main(String[] args)
        {
           Scanner scan = new Scanner(System.in); // you shod use this scanner object for getting inputs
    
    
            System.out.print("Enter a dollar amount: ");
            double dollars = scan.nextDouble(); 
    
            System.out.println("Enter the currency to convert to (1) euro, (2) pound, (3) taka, (4) yen, (5) rupees : ");
            int response = scan.nextInt();
    
            // ...
            CurrencyExchange currencyExchange = new CurrencyExchange(dollars);
    
            switch (response)
            {
               case 1: // modified here to get the exact results as you need.
                   currencyExchange.setEuro(dollars); // this will convert the entered dollar into euros
                   System.out.println(currencyExchange.getEuro());// this will display the result
                   break;
               //...change all other cases accordingly
            }
    
        }
    }
    

    i would recommend you to use eclipse like IDE’s , it will guide you as you write. Read more java books.

    Good luck.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get some currency exchange rates in a seperate php file in
I have an $.ajax() request that queries currency exchange rate information from another web
Assume that you are developing a web application that shows currency exchange rates for
How do I link live currency exchange rates to my iPhone app? First, anyone
Arbitrage is the process of using discrepancies in currency exchange values to earn profit.
I am writing a Java currency exchange program, in which I program 3 foreign
I have a list of exchange rates categorised by currency, that I need to
Currently Virtuemart uses a converter module: convertECB.php . Such module fetches exchange rates from
How can i format currency related data in a manner that is culture aware
For the currency code ISO 4217, how do I retrieve the numeric value from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.