Results 1 to 15 of 15
  1. #1
    xhanis is offline Member
    Join Date
    Mar 2013
    Posts
    12
    Rep Power
    0

    Default currency converter problem help

    i have this question can somebody teach me how construct it

    Design a currency Converter class whose object will handle conversion of three currencies (Dollar, Ringgit, Pound). A single object of the new currency Converter class you design here will handle all these three currencies. Instead of having specific conversion methods such as toDollar, toPound and so forth, the new currency Converter class supports one generic conversion method call exchange. The method has three arguments: fromCurrency, toCurrency and amount. The first two arguments are String and give the names of currencies. The third argument is the amount that need to be converted. For example, to convert RM250 to dollar, we write:

    dollar = converter.exchange(‘ringgit”, “dollar”, 250.0);


    To set the exchange rate for a currency, we use the setRate method. This method takes three arguments. The first two arguments are the currency names, and the third argument is the rate. For example, if the exchange rate for dollar is 3.4 Dollar to RM1, then we write:

    converter.setRate(“dollar”, “ringgit”, 3.4);

    In addition, the class also have the following method:

    updateRate (“fromCurrency”, “toCurrency”, newRate) - The first two arguments are the currency names, and the third argument is the new exchange rate.


    Finally, test your program by creating its object in the main() method.

    i have some dificulty on how to do it can somebody show me how build and hope i can learn it thank


    how many class do i need to build
    how many variable i need to know and lastly how to build it

    thank

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: currency converter problem help

    You ignored 4 responses in your earlier thread: error on running java code so why should we expect any better behavior this time round?

    Also, your post -- as it stands -- is nothing more than a homework dump. Post your best efforts at a solution, indicate where exactly you're stuck and someone will guide you to the next step. Or wait for someone to do your homework for you and you'll wait in vain.

    Recommended reading: How to ask questions the smart way

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    xhanis is offline Member
    Join Date
    Mar 2013
    Posts
    12
    Rep Power
    0

    Default Re: currency converter problem help

    okay

    i think of some of the thing i got in my right now

    class Currencyconverter{

    public static void main (String [] args){


    from here im stuck cannot go on can sombody show me what dto do next

    i think of having six of set currency exchange

    dollar to ringgit;
    dollar to pound;
    ringgit to dollar
    ringgit to pound
    pound to ringgit
    pound to dollar

    dont know the idea on how to set set the converter

    stuck here

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,336
    Blog Entries
    7
    Rep Power
    20

    Default Re: currency converter problem help

    Quote Originally Posted by xhanis View Post
    dollar to ringgit;
    dollar to pound;
    ringgit to dollar
    ringgit to pound
    pound to ringgit
    pound to dollar
    Have you read your own assignment text?

    Quote Originally Posted by assignment text
    Instead of having specific conversion methods such as toDollar, toPound and so forth, the new currency Converter class supports one generic conversion method call exchange
    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    xhanis is offline Member
    Join Date
    Mar 2013
    Posts
    12
    Rep Power
    0

    Default Re: currency converter problem help

    so now to create a new class call exchange right

    class Exchange{

    public static main void (String[]args){

    converter.setRate(“dollar”, “ringgit”, 3.4);
    converter.setRate(“dollar”, “pound”, 2.0);
    converter.setRate(“ringgit”, “dollar”, 3.4);
    converter.setRate(“ringgit”, “pound”, 1.0);
    converter.setRate(“pound”, “ringgit”, 6.0);
    converter.setRate(“pound”, “dollar”, 3.0);

    updateRate (“fromCurrency”, “toCurrency”, newRate)

    System.println("new currency value");

    }

    }

  6. #6
    xhanis is offline Member
    Join Date
    Mar 2013
    Posts
    12
    Rep Power
    0

    Default Re: currency converter problem help

    can you check the table is it right or wrong

  7. #7
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,336
    Blog Entries
    7
    Rep Power
    20

    Default Re: currency converter problem help

    Your assignment asks you to create one Converter class with a 'generic' exchange( ... ) method; also if for currencies A and B the exchange rate is 'r', so A= r*B then A/B == r but also B/A == 1/r so your exchange rates in your previous reply are wrong.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  8. #8
    xhanis is offline Member
    Join Date
    Mar 2013
    Posts
    12
    Rep Power
    0

    Default Re: currency converter problem help

    can show how to write it im not very sure on how to construct it

  9. #9
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: currency converter problem help

    Quote Originally Posted by xhanis View Post
    can show how to write it im not very sure on how to construct it
    We don't write your code for you here. Why take away a great opportunity for you to learn? What exactly confuses you?

  10. #10
    xhanis is offline Member
    Join Date
    Mar 2013
    Posts
    12
    Rep Power
    0

    Default Re: currency converter problem help

    now im trying again but i dont know on how to write this 'generic' exchange( ... ) method;

    also if for currencies A and B the exchange rate is 'r', so A= r*B then A/B == r but also B/A == 1/r
    how to put this method are we need to get a new class

  11. #11
    xhanis is offline Member
    Join Date
    Mar 2013
    Posts
    12
    Rep Power
    0

    Default Re: currency converter problem help

    can you show some then i try figure out if im stuck again ill ask

  12. #12
    xhanis is offline Member
    Join Date
    Mar 2013
    Posts
    12
    Rep Power
    0

    Default Re: currency converter problem help

    for the time being i try this one

    class Exchange{
    public static main void (String [] args){

    public dollar;
    public ringgit;
    public pound;
    public newRate;

    public exchange("first Currency","next Currency","newRate");



    }
    }

  13. #13
    xhanis is offline Member
    Join Date
    Mar 2013
    Posts
    12
    Rep Power
    0

    Default Re: currency converter problem help

    is this correct or still wrong also have no idea on how to do if A*r = B

    didnot know on how to fill in

  14. #14
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,336
    Blog Entries
    7
    Rep Power
    20

    Default Re: currency converter problem help

    Quote Originally Posted by xhanis View Post
    is this correct or still wrong also have no idea on how to do if A*r = B

    didnot know on how to fill in
    No, I'm sorry, it isn't correct and programming isn't filling in the dots, nor is it a trial and error exercise. I only gave you a simple formula (and a hint): if you know the exchange rate between monetary units A and B, such that B == r*A, you also know the exchange rate between B and A; it is 1/r.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  15. #15
    xhanis is offline Member
    Join Date
    Mar 2013
    Posts
    12
    Rep Power
    0

    Default Re: currency converter problem help

    okay ill try again later

Similar Threads

  1. Replies: 4
    Last Post: 06-13-2012, 05:21 AM
  2. Replies: 5
    Last Post: 03-28-2012, 11:16 AM
  3. Currency Converter Applet Help...
    By MarkL410 in forum Java Applets
    Replies: 3
    Last Post: 11-09-2010, 05:27 PM
  4. Replies: 3
    Last Post: 06-10-2010, 03:42 PM
  5. Currency Converter!!!!
    By Pascal Nouma in forum AWT / Swing
    Replies: 2
    Last Post: 04-02-2009, 07:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •