write small currency converter

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mereba

    #1

    write small currency converter

    Hello
    My country Ghana is changing its currency. I want to write a small
    programme in C++ that can covert from the old currency into the new
    one. I would like this programme to run behind a simple calculator-
    looking interface. I'm quite new to C++, and I would need some help.
    Please any suggestion is welcome :)

    The following is what I have been able to do so far:


    #include <iostream>
    using namespace std;

    int main(){
    //variables declared

    int old_currency_va lue, new_currency_va lue, result_of_formu la;

    //questions to ask user

    cout<< "Please enter the value of the old currency you wish to
    convert";
    cin >old_currency_v alue;

    //conversion implementation
    new_currency_va lue = old_currency_va lue/10000;

    cout << "The value of the new currency is " << new_currency_va lue <<
    endl;

    //quit programme

    return 0;

  • Jim Langston

    #2
    Re: write small currency converter

    "mereba" <jojoo.imbeah@g mail.comwrote in message
    news:1183458511 .013010.186940@ m36g2000hse.goo glegroups.com.. .
    Hello
    My country Ghana is changing its currency. I want to write a small
    programme in C++ that can covert from the old currency into the new
    one. I would like this programme to run behind a simple calculator-
    looking interface. I'm quite new to C++, and I would need some help.
    Please any suggestion is welcome :)
    >
    The following is what I have been able to do so far:
    >
    >
    #include <iostream>
    using namespace std;
    >
    int main(){
    //variables declared
    >
    int old_currency_va lue, new_currency_va lue, result_of_formu la;
    >
    //questions to ask user
    >
    cout<< "Please enter the value of the old currency you wish to
    convert";
    cin >old_currency_v alue;
    >
    //conversion implementation
    new_currency_va lue = old_currency_va lue/10000;
    >
    cout << "The value of the new currency is " << new_currency_va lue <<
    endl;
    >
    //quit programme
    >
    return 0;
    So what is your question?


    Comment

    • mereba

      #3
      Re: write small currency converter

      On Jul 3, 10:30 am, "Jim Langston" <tazmas...@rock etmail.comwrote :
      "mereba" <jojoo.imb...@g mail.comwrote in message
      >
      news:1183458511 .013010.186940@ m36g2000hse.goo glegroups.com.. .
      >
      >
      >
      Hello
      My country Ghana is changing its currency. I want to write a small
      programme in C++ that can covert from the old currency into the new
      one. I would like this programme to run behind a simple calculator-
      looking interface. I'm quite new to C++, and I would need some help.
      Please any suggestion is welcome :)
      >
      The following is what I have been able to do so far:
      >
      #include <iostream>
      using namespace std;
      >
      int main(){
      //variables declared
      >
      int old_currency_va lue, new_currency_va lue, result_of_formu la;
      >
      //questions to ask user
      >
      cout<< "Please enter the value of the old currency you wish to
      convert";
      cin >old_currency_v alue;
      >
      //conversion implementation
      new_currency_va lue = old_currency_va lue/10000;
      >
      cout << "The value of the new currency is " << new_currency_va lue <<
      endl;
      >
      //quit programme
      >
      return 0;
      >
      So what is your question?
      Thanks for your quick response

      1. How do I write a gui in C++ for this programme?
      2. Do you have any suggestions for enhancing this programme?

      Comment

      • Jim Langston

        #4
        Re: write small currency converter

        "mereba" <jojoo.imbeah@g mail.comwrote in message
        news:1183459708 .587981.228340@ m36g2000hse.goo glegroups.com.. .
        On Jul 3, 10:30 am, "Jim Langston" <tazmas...@rock etmail.comwrote :
        >"mereba" <jojoo.imb...@g mail.comwrote in message
        >>
        >news:118345851 1.013010.186940 @m36g2000hse.go oglegroups.com. ..
        >>
        >>
        >>
        Hello
        My country Ghana is changing its currency. I want to write a small
        programme in C++ that can covert from the old currency into the new
        one. I would like this programme to run behind a simple calculator-
        looking interface. I'm quite new to C++, and I would need some help.
        Please any suggestion is welcome :)
        >>
        The following is what I have been able to do so far:
        >>
        #include <iostream>
        using namespace std;
        >>
        int main(){
        //variables declared
        >>
        int old_currency_va lue, new_currency_va lue, result_of_formu la;
        >>
        //questions to ask user
        >>
        cout<< "Please enter the value of the old currency you wish to
        convert";
        cin >old_currency_v alue;
        >>
        //conversion implementation
        new_currency_va lue = old_currency_va lue/10000;
        >>
        cout << "The value of the new currency is " << new_currency_va lue <<
        endl;
        >>
        //quit programme
        >>
        return 0;
        >>
        >So what is your question?
        >
        Thanks for your quick response
        >
        1. How do I write a gui in C++ for this programme?
        GUI is beyond the scope of this newsgroup, it is platform dependant. Ask in
        a newsgroup dedicated to your OS/platform (alt.windows... etc.., alt.linux,
        whatever).
        2. Do you have any suggestions for enhancing this programme?
        Write a GUI for it. Of course, you'll need to get information somewhere,
        try in a newsgroup for your OS


        Comment

        • mereba

          #5
          Re: write small currency converter

          On Jul 3, 10:58 am, "Jim Langston" <tazmas...@rock etmail.comwrote :
          "mereba" <jojoo.imb...@g mail.comwrote in message
          >
          news:1183459708 .587981.228340@ m36g2000hse.goo glegroups.com.. .
          >
          >
          >
          On Jul 3, 10:30 am, "Jim Langston" <tazmas...@rock etmail.comwrote :
          "mereba" <jojoo.imb...@g mail.comwrote in message
          >
          >news:118345851 1.013010.186940 @m36g2000hse.go oglegroups.com. ..
          >
          Hello
          My country Ghana is changing its currency. I want to write a small
          programme in C++ that can covert from the old currency into the new
          one. I would like this programme to run behind a simple calculator-
          looking interface. I'm quite new to C++, and I would need some help.
          Please any suggestion is welcome :)
          >
          The following is what I have been able to do so far:
          >
          #include <iostream>
          using namespace std;
          >
          int main(){
          //variables declared
          >
          int old_currency_va lue, new_currency_va lue, result_of_formu la;
          >
          //questions to ask user
          >
          cout<< "Please enter the value of the old currency you wish to
          convert";
          cin >old_currency_v alue;
          >
          //conversion implementation
          new_currency_va lue = old_currency_va lue/10000;
          >
          cout << "The value of the new currency is " << new_currency_va lue <<
          endl;
          >
          //quit programme
          >
          return 0;
          >
          So what is your question?
          >
          Thanks for your quick response
          >
          1. How do I write a gui in C++ for this programme?
          >
          GUI is beyond the scope of this newsgroup, it is platform dependant. Ask in
          a newsgroup dedicated to your OS/platform (alt.windows... etc.., alt.linux,
          whatever).
          >
          2. Do you have any suggestions for enhancing this programme?
          >
          Write a GUI for it. Of course, you'll need to get information somewhere,
          try in a newsgroup for your OS
          Jim,
          I'm using Gtk, and I thought code was code? Thanks for your
          suggestions, but can I not get any real direct answers to my
          questions?


          Comment

          • Zeppe

            #6
            Re: write small currency converter

            mereba wrote:
            Hello
            My country Ghana is changing its currency. I want to write a small
            programme in C++ that can covert from the old currency into the new
            one. I would like this programme to run behind a simple calculator-
            looking interface. I'm quite new to C++, and I would need some help.
            Please any suggestion is welcome :)
            >
            The following is what I have been able to do so far:
            >
            >
            #include <iostream>
            using namespace std;
            >
            int main(){
            //variables declared
            >
            int old_currency_va lue, new_currency_va lue, result_of_formu la;
            are you sure that an integer will suit? in some machine the integer
            range is not so big. And you may want to store decimal digits.

            //questions to ask user
            >
            cout<< "Please enter the value of the old currency you wish to
            convert";
            cin >old_currency_v alue;
            >
            //conversion implementation
            new_currency_va lue = old_currency_va lue/10000;
            if old currency value was 19999, new_currency_va lue would be 1. Are you
            sure that you want this to happen?


            For a GUI, I'll suggest you to use qt. But beware: it's not as easy as
            writing a simple console program!

            Regards,

            Zeppe

            Comment

            • mereba

              #7
              Re: write small currency converter

              On Jul 3, 12:26 pm, Zeppe
              <zep_p@.remove. all.this.long.c omment.yahoo.it wrote:
              mereba wrote:
              Hello
              My country Ghana is changing its currency. I want to write a small
              programme in C++ that can covert from the old currency into the new
              one. I would like this programme to run behind a simple calculator-
              looking interface. I'm quite new to C++, and I would need some help.
              Please any suggestion is welcome :)
              >
              The following is what I have been able to do so far:
              >
              #include <iostream>
              using namespace std;
              >
              int main(){
              //variables declared
              >
              int old_currency_va lue, new_currency_va lue, result_of_formu la;
              >
              are you sure that an integer will suit? in some machine the integer
              range is not so big. And you may want to store decimal digits.
              >
              //questions to ask user
              >
              cout<< "Please enter the value of the old currency you wish to
              convert";
              cin >old_currency_v alue;
              >
              //conversion implementation
              new_currency_va lue = old_currency_va lue/10000;
              >
              if old currency value was 19999, new_currency_va lue would be 1. Are you
              sure that you want this to happen?
              >
              For a GUI, I'll suggest you to use qt. But beware: it's not as easy as
              writing a simple console program!
              >
              Regards,
              >
              Zeppe
              Thanks to all who made suggestions. Thank you to Zeppe for your
              advice. I'm changing all the data types to double. Thanks for the
              suggestion to use qt. Any more suggestions on improving this basic
              code is welcome.

              Comment

              • Daniel T.

                #8
                Re: write small currency converter

                mereba <jojoo.imbeah@g mail.comwrote:
                My country Ghana is changing its currency. I want to write a small
                programme in C++ that can covert from the old currency into the new
                one. I would like this programme to run behind a simple calculator-
                looking interface. I'm quite new to C++, and I would need some help.
                Please any suggestion is welcome :)
                Frankly, it sounds like homework. Google, "Ghana currency converter" and
                you will find dozens of them.
                The following is what I have been able to do so far:
                >
                >
                #include <iostream>
                using namespace std;
                >
                int main(){
                //variables declared
                >
                int old_currency_va lue, new_currency_va lue, result_of_formu la;
                >
                //questions to ask user
                >
                cout<< "Please enter the value of the old currency you wish to
                convert";
                cin >old_currency_v alue;
                >
                //conversion implementation
                new_currency_va lue = old_currency_va lue/10000;
                >
                cout << "The value of the new currency is " << new_currency_va lue <<
                endl;
                >
                //quit programme
                >
                return 0;
                Your missing the close paren at the end, otherwise your program will
                compile and run. Is the output what you expected?

                Comment

                • mereba

                  #9
                  Re: write small currency converter

                  On Jul 3, 1:35 pm, "Daniel T." <danie...@earth link.netwrote:
                  mereba <jojoo.imb...@g mail.comwrote:
                  My country Ghana is changing its currency. I want to write a small
                  programme in C++ that can covert from the old currency into the new
                  one. I would like this programme to run behind a simple calculator-
                  looking interface. I'm quite new to C++, and I would need some help.
                  Please any suggestion is welcome :)
                  >
                  Frankly, it sounds like homework. Google, "Ghana currency converter" and
                  you will find dozens of them.
                  >
                  >
                  >
                  The following is what I have been able to do so far:
                  >
                  #include <iostream>
                  using namespace std;
                  >
                  int main(){
                  //variables declared
                  >
                  int old_currency_va lue, new_currency_va lue, result_of_formu la;
                  >
                  //questions to ask user
                  >
                  cout<< "Please enter the value of the old currency you wish to
                  convert";
                  cin >old_currency_v alue;
                  >
                  //conversion implementation
                  new_currency_va lue = old_currency_va lue/10000;
                  >
                  cout << "The value of the new currency is " << new_currency_va lue <<
                  endl;
                  >
                  //quit programme
                  >
                  return 0;
                  >
                  Your missing the close paren at the end, otherwise your program will
                  compile and run. Is the output what you expected?
                  This is no joke Daniel T :).My country is CHANGING its currency. I'm
                  not looking for some fancy converters from the old Ghana cedi to US
                  dollars and other currencies. I'm looking to write my own programme
                  that can convert from the old Ghana cedi to the NEW Ghana cedi, and I
                  intend to do just that with C++. Thanks for the tip about closing
                  parentheses. It is well noted. Please more suggestions are welcome.
                  The source code now looks like this:

                  #include <iostream>
                  using namespace std;

                  int main(){
                  //variables declared

                  double old_currency_va lue, new_currency_va lue, result_of_formu la;
                  double value_in_pessew as; //datatypes changed to double. suggested by
                  Zeppe of
                  //comp.lang.c++ google group

                  //questions to ask user

                  cout<< "Please enter the value of the old currency you wish to convert
                  " << endl;
                  cin >old_currency_v alue;

                  //conversion implementation
                  if (old_currency_v alue<10000){ //suggested by Reuben
                  value_in_pessew as= old_currency_va lue/100;
                  new_currency_va lue= value_in_pessew as;
                  }
                  else
                  new_currency_va lue = old_currency_va lue/10000;

                  cout << "The value of the new currency is " << new_currency_va lue <<
                  endl;

                  //quit programme
                  return 0;
                  }

                  Comment

                  • =?ISO-8859-1?Q?Erik_Wikstr=F6m?=

                    #10
                    Re: write small currency converter

                    On 2007-07-03 17:23, mereba wrote:
                    On Jul 3, 1:35 pm, "Daniel T." <danie...@earth link.netwrote:
                    >mereba <jojoo.imb...@g mail.comwrote:
                    My country Ghana is changing its currency. I want to write a small
                    programme in C++ that can covert from the old currency into the new
                    one. I would like this programme to run behind a simple calculator-
                    looking interface. I'm quite new to C++, and I would need some help.
                    Please any suggestion is welcome :)
                    >>
                    >Frankly, it sounds like homework. Google, "Ghana currency converter" and
                    >you will find dozens of them.
                    >>
                    >>
                    >>
                    The following is what I have been able to do so far:
                    >>
                    #include <iostream>
                    using namespace std;
                    >>
                    int main(){
                    //variables declared
                    >>
                    int old_currency_va lue, new_currency_va lue, result_of_formu la;
                    >>
                    //questions to ask user
                    >>
                    cout<< "Please enter the value of the old currency you wish to
                    convert";
                    cin >old_currency_v alue;
                    >>
                    //conversion implementation
                    new_currency_va lue = old_currency_va lue/10000;
                    >>
                    cout << "The value of the new currency is " << new_currency_va lue <<
                    endl;
                    >>
                    //quit programme
                    >>
                    return 0;
                    >>
                    >Your missing the close paren at the end, otherwise your program will
                    >compile and run. Is the output what you expected?
                    >
                    This is no joke Daniel T :).My country is CHANGING its currency. I'm
                    not looking for some fancy converters from the old Ghana cedi to US
                    dollars and other currencies. I'm looking to write my own programme
                    that can convert from the old Ghana cedi to the NEW Ghana cedi, and I
                    intend to do just that with C++. Thanks for the tip about closing
                    parentheses. It is well noted. Please more suggestions are welcome.
                    The source code now looks like this:
                    Looks quite good, there is one problem though, if I input 5000 and
                    500000 I get the same result (50) because you don't tell the user the
                    type of the answer.

                    Also notice that the variable result_of_formu la is never used so you can
                    delete it. You can also, if you wish, get rid of the variables
                    new_currency_va lue and value_in_pessew as by performing the calculations
                    in the if-statement, like this:

                    #include <iostream>
                    using namespace std;

                    int main() {
                    double old;

                    cout << "Please enter the value of the old currency"
                    "you wish to convert" << endl;
                    cin >old;

                    if (old < 10000) {
                    cout << "The value of the new currency is "
                    << old / 100 << " pessewas" << endl;
                    }
                    else {
                    cout << "The value if the new currency is "
                    << old / 10000 << " cedi" << endl;
                    }
                    return 0;
                    }

                    --
                    Erik Wikström

                    Comment

                    • mereba

                      #11
                      Re: write small currency converter

                      On Jul 3, 5:11 pm, Erik Wikström <Erik-wikst...@telia. comwrote:
                      On 2007-07-03 17:23, mereba wrote:
                      >
                      >
                      >
                      On Jul 3, 1:35 pm, "Daniel T." <danie...@earth link.netwrote:
                      mereba <jojoo.imb...@g mail.comwrote:
                      My country Ghana is changing its currency. I want to write a small
                      programme in C++ that can covert from the old currency into the new
                      one. I would like this programme to run behind a simple calculator-
                      looking interface. I'm quite new to C++, and I would need some help.
                      Please any suggestion is welcome :)
                      >
                      Frankly, it sounds like homework. Google, "Ghana currency converter" and
                      you will find dozens of them.
                      >
                      The following is what I have been able to do so far:
                      >
                      #include <iostream>
                      using namespace std;
                      >
                      int main(){
                      //variables declared
                      >
                      int old_currency_va lue, new_currency_va lue, result_of_formu la;
                      >
                      //questions to ask user
                      >
                      cout<< "Please enter the value of the old currency you wish to
                      convert";
                      cin >old_currency_v alue;
                      >
                      //conversion implementation
                      new_currency_va lue = old_currency_va lue/10000;
                      >
                      cout << "The value of the new currency is " << new_currency_va lue <<
                      endl;
                      >
                      //quit programme
                      >
                      return 0;
                      >
                      Your missing the close paren at the end, otherwise your program will
                      compile and run. Is the output what you expected?
                      >
                      This is no joke Daniel T :).My country is CHANGING its currency. I'm
                      not looking for some fancy converters from the old Ghana cedi to US
                      dollars and other currencies. I'm looking to write my own programme
                      that can convert from the old Ghana cedi to the NEW Ghana cedi, and I
                      intend to do just that with C++. Thanks for the tip about closing
                      parentheses. It is well noted. Please more suggestions are welcome.
                      The source code now looks like this:
                      >
                      Looks quite good, there is one problem though, if I input 5000 and
                      500000 I get the same result (50) because you don't tell the user the
                      type of the answer.
                      >
                      Also notice that the variable result_of_formu la is never used so you can
                      delete it. You can also, if you wish, get rid of the variables
                      new_currency_va lue and value_in_pessew as by performing the calculations
                      in the if-statement, like this:
                      >
                      #include <iostream>
                      using namespace std;
                      >
                      int main() {
                      double old;
                      >
                      cout << "Please enter the value of the old currency"
                      "you wish to convert" << endl;
                      cin >old;
                      >
                      if (old < 10000) {
                      cout << "The value of the new currency is "
                      << old / 100 << " pessewas" << endl;
                      }
                      else {
                      cout << "The value if the new currency is "
                      << old / 10000 << " cedi" << endl;
                      }
                      return 0;
                      >
                      }
                      >
                      --
                      Erik Wikström
                      Many thanks Erik
                      You have given me valuable information. I guess you're right with the
                      50 result. I need to specify which denomination -cedis or pessewas-
                      i'm talking about. True. I'll rewrite the code and make the
                      modifications you have suggested. Thank you very much indeed. Any more
                      suggestions for this small program are welcome.

                      Comment

                      • Zachary  Turner

                        #12
                        Re: write small currency converter

                        On Jul 3, 2:00 pm, mereba <jojoo.imb...@g mail.comwrote:
                        On Jul 3, 5:11 pm, Erik Wikström <Erik-wikst...@telia. comwrote:
                        >
                        >
                        >
                        >
                        >
                        On 2007-07-03 17:23, mereba wrote:
                        >
                        On Jul 3, 1:35 pm, "Daniel T." <danie...@earth link.netwrote:
                        >mereba <jojoo.imb...@g mail.comwrote:
                        My country Ghana is changing its currency. I want to write a small
                        programme in C++ that can covert from the old currency into the new
                        one. I would like this programme to run behind a simple calculator-
                        looking interface. I'm quite new to C++, and I would need some help.
                        Please any suggestion is welcome :)
                        >
                        >Frankly, it sounds like homework. Google, "Ghana currency converter"and
                        >you will find dozens of them.
                        >
                        The following is what I have been able to do so far:
                        >
                        #include <iostream>
                        using namespace std;
                        >
                        int main(){
                        //variables declared
                        >
                        int old_currency_va lue, new_currency_va lue, result_of_formu la;
                        >
                        //questions to ask user
                        >
                        cout<< "Please enter the value of the old currency you wish to
                        convert";
                        cin >old_currency_v alue;
                        >
                        //conversion implementation
                        new_currency_va lue = old_currency_va lue/10000;
                        >
                        cout << "The value of the new currency is " << new_currency_va lue <<
                        endl;
                        >
                        //quit programme
                        >
                        return 0;
                        >
                        >Your missing the close paren at the end, otherwise your program will
                        >compile and run. Is the output what you expected?
                        >
                        This is no joke Daniel T :).My country is CHANGING its currency. I'm
                        not looking for some fancy converters from the old Ghana cedi to US
                        dollars and other currencies. I'm looking to write my own programme
                        that can convert from the old Ghana cedi to the NEW Ghana cedi, and I
                        intend to do just that with C++. Thanks for the tip about closing
                        parentheses. It is well noted. Please more suggestions are welcome.
                        The source code now looks like this:
                        >
                        Looks quite good, there is one problem though, if I input 5000 and
                        500000 I get the same result (50) because you don't tell the user the
                        type of the answer.
                        >
                        Also notice that the variable result_of_formu la is never used so you can
                        delete it. You can also, if you wish, get rid of the variables
                        new_currency_va lue and value_in_pessew as by performing the calculations
                        in the if-statement, like this:
                        >
                        #include <iostream>
                        using namespace std;
                        >
                        int main() {
                        double old;
                        >
                        cout << "Please enter the value of the old currency"
                        "you wish to convert" << endl;
                        cin >old;
                        >
                        if (old < 10000) {
                        cout << "The value of the new currency is "
                        << old / 100 << " pessewas" << endl;
                        }
                        else {
                        cout << "The value if the new currency is "
                        << old / 10000 << " cedi" << endl;
                        }
                        return 0;
                        >
                        }
                        >
                        --
                        Erik Wikström
                        >
                        Many thanks Erik
                        You have given me valuable information. I guess you're right with the
                        50 result. I need to specify which denomination -cedis or pessewas-
                        i'm talking about. True. I'll rewrite the code and make the
                        modifications you have suggested. Thank you very much indeed. Any more
                        suggestions for this small program are welcome.- Hide quoted text -
                        >
                        - Show quoted text -
                        It would be niec if you could specify command line options. That way
                        no user input is really needed. From your post it looks like either
                        the old or new currency is called "cedis" and the other one is called
                        "pessewas". So, wouldn't it be niec if you could type something like
                        this?

                        $convert 1000p
                        1000 pessewas is 4705 cedis

                        $convert 1000c
                        1000 cedis is 200 pessewas


                        The following inputs might be nice also

                        $convert
                        Enter the amount to convert: 1000c
                        1000 cedis is 200 pessewas

                        $convert
                        Enter the amount to convert: 1000
                        1000 pessewas or cedis? p
                        1000 pessewas is 4705 cedis


                        To read command line arguments, you will need to first declare main
                        function differently:

                        int main(int argc, char** argv)
                        {
                        }

                        Then, use argc and argv parameters to the main function. argc = 1 if
                        no additional parameters are specified on the command line (because
                        "convert" is always the first parameter) 2 if one additional
                        parameters are specified, etc). argv is an array of command line
                        parameters. So, for example say you run the program like this:

                        $convert 1000p

                        Then, argc=2 and argv = { "convert", "1000p" }

                        Good luck.

                        Comment

                        • mereba

                          #13
                          Re: write small currency converter

                          On Jul 3, 7:00 pm, mereba <jojoo.imb...@g mail.comwrote:
                          On Jul 3, 5:11 pm, Erik Wikström <Erik-wikst...@telia. comwrote:
                          >
                          >
                          >
                          On 2007-07-03 17:23, mereba wrote:
                          >
                          On Jul 3, 1:35 pm, "Daniel T." <danie...@earth link.netwrote:
                          >mereba <jojoo.imb...@g mail.comwrote:
                          My country Ghana is changing its currency. I want to write a small
                          programme in C++ that can covert from the old currency into the new
                          one. I would like this programme to run behind a simple calculator-
                          looking interface. I'm quite new to C++, and I would need some help.
                          Please any suggestion is welcome :)
                          >
                          >Frankly, it sounds like homework. Google, "Ghana currency converter"and
                          >you will find dozens of them.
                          >
                          The following is what I have been able to do so far:
                          >
                          #include <iostream>
                          using namespace std;
                          >
                          int main(){
                          //variables declared
                          >
                          int old_currency_va lue, new_currency_va lue, result_of_formu la;
                          >
                          //questions to ask user
                          >
                          cout<< "Please enter the value of the old currency you wish to
                          convert";
                          cin >old_currency_v alue;
                          >
                          //conversion implementation
                          new_currency_va lue = old_currency_va lue/10000;
                          >
                          cout << "The value of the new currency is " << new_currency_va lue <<
                          endl;
                          >
                          //quit programme
                          >
                          return 0;
                          >
                          >Your missing the close paren at the end, otherwise your program will
                          >compile and run. Is the output what you expected?
                          >
                          This is no joke Daniel T :).My country is CHANGING its currency. I'm
                          not looking for some fancy converters from the old Ghana cedi to US
                          dollars and other currencies. I'm looking to write my own programme
                          that can convert from the old Ghana cedi to the NEW Ghana cedi, and I
                          intend to do just that with C++. Thanks for the tip about closing
                          parentheses. It is well noted. Please more suggestions are welcome.
                          The source code now looks like this:
                          >
                          Looks quite good, there is one problem though, if I input 5000 and
                          500000 I get the same result (50) because you don't tell the user the
                          type of the answer.
                          >
                          Also notice that the variable result_of_formu la is never used so you can
                          delete it. You can also, if you wish, get rid of the variables
                          new_currency_va lue and value_in_pessew as by performing the calculations
                          in the if-statement, like this:
                          >
                          #include <iostream>
                          using namespace std;
                          >
                          int main() {
                          double old;
                          >
                          cout << "Please enter the value of the old currency"
                          "you wish to convert" << endl;
                          cin >old;
                          >
                          if (old < 10000) {
                          cout << "The value of the new currency is "
                          << old / 100 << " pessewas" << endl;
                          }
                          else {
                          cout << "The value if the new currency is "
                          << old / 10000 << " cedi" << endl;
                          }
                          return 0;
                          >
                          }
                          >
                          --
                          Erik Wikström
                          >
                          Many thanks Erik
                          You have given me valuable information. I guess you're right with the
                          50 result. I need to specify which denomination -cedis or pessewas-
                          i'm talking about. True. I'll rewrite the code and make the
                          modifications you have suggested. Thank you very much indeed. Any more
                          suggestions for this small program are welcome.
                          OK. I just compiled and run Erik's rewrite, and it works perfectly. I
                          guess I'm now left to figure out how to write a GUI for this small
                          program. Earlier posters have advised that I should join other forums
                          for topics about GUIs. However, I would very much like for the people
                          who pointed me to all the right directions to suggest GUI tools that I
                          should try out and select. I would want to be able to let this program
                          run on both windows and linux systems.
                          Many thanks!

                          Comment

                          • mereba

                            #14
                            Re: write small currency converter

                            On Jul 3, 7:09 pm, Zachary Turner <divisorthe...@ gmail.comwrote:
                            On Jul 3, 2:00 pm, mereba <jojoo.imb...@g mail.comwrote:
                            >
                            >
                            >
                            On Jul 3, 5:11 pm, Erik Wikström <Erik-wikst...@telia. comwrote:
                            >
                            On 2007-07-03 17:23, mereba wrote:
                            >
                            On Jul 3, 1:35 pm, "Daniel T." <danie...@earth link.netwrote:
                            mereba <jojoo.imb...@g mail.comwrote:
                            My country Ghana is changing its currency. I want to write a small
                            programme in C++ that can covert from the old currency into the new
                            one. I would like this programme to run behind a simple calculator-
                            looking interface. I'm quite new to C++, and I would need some help.
                            Please any suggestion is welcome :)
                            >
                            Frankly, it sounds like homework. Google, "Ghana currency converter" and
                            you will find dozens of them.
                            >
                            The following is what I have been able to do so far:
                            >
                            #include <iostream>
                            using namespace std;
                            >
                            int main(){
                            //variables declared
                            >
                            int old_currency_va lue, new_currency_va lue, result_of_formu la;
                            >
                            //questions to ask user
                            >
                            cout<< "Please enter the value of the old currency you wish to
                            convert";
                            cin >old_currency_v alue;
                            >
                            //conversion implementation
                            new_currency_va lue = old_currency_va lue/10000;
                            >
                            cout << "The value of the new currency is " << new_currency_va lue <<
                            endl;
                            >
                            //quit programme
                            >
                            return 0;
                            >
                            Your missing the close paren at the end, otherwise your program will
                            compile and run. Is the output what you expected?
                            >
                            This is no joke Daniel T :).My country is CHANGING its currency. I'm
                            not looking for some fancy converters from the old Ghana cedi to US
                            dollars and other currencies. I'm looking to write my own programme
                            that can convert from the old Ghana cedi to the NEW Ghana cedi, andI
                            intend to do just that with C++. Thanks for the tip about closing
                            parentheses. It is well noted. Please more suggestions are welcome.
                            The source code now looks like this:
                            >
                            Looks quite good, there is one problem though, if I input 5000 and
                            500000 I get the same result (50) because you don't tell the user the
                            type of the answer.
                            >
                            Also notice that the variable result_of_formu la is never used so you can
                            delete it. You can also, if you wish, get rid of the variables
                            new_currency_va lue and value_in_pessew as by performing the calculations
                            in the if-statement, like this:
                            >
                            #include <iostream>
                            using namespace std;
                            >
                            int main() {
                            double old;
                            >
                            cout << "Please enter the value of the old currency"
                            "you wish to convert" << endl;
                            cin >old;
                            >
                            if (old < 10000) {
                            cout << "The value of the new currency is "
                            << old / 100 << " pessewas" << endl;
                            }
                            else {
                            cout << "The value if the new currency is "
                            << old / 10000 << " cedi" << endl;
                            }
                            return 0;
                            >
                            }
                            >
                            --
                            Erik Wikström
                            >
                            Many thanks Erik
                            You have given me valuable information. I guess you're right with the
                            50 result. I need to specify which denomination -cedis or pessewas-
                            i'm talking about. True. I'll rewrite the code and make the
                            modifications you have suggested. Thank you very much indeed. Any more
                            suggestions for this small program are welcome.- Hide quoted text -
                            >
                            - Show quoted text -
                            >
                            It would be niec if you could specify command line options. That way
                            no user input is really needed. From your post it looks like either
                            the old or new currency is called "cedis" and the other one is called
                            "pessewas". So, wouldn't it be niec if you could type something like
                            this?
                            >
                            $convert 1000p
                            1000 pessewas is 4705 cedis
                            >
                            $convert 1000c
                            1000 cedis is 200 pessewas
                            >
                            The following inputs might be nice also
                            >
                            $convert
                            Enter the amount to convert: 1000c
                            1000 cedis is 200 pessewas
                            >
                            $convert
                            Enter the amount to convert: 1000
                            1000 pessewas or cedis? p
                            1000 pessewas is 4705 cedis
                            >
                            To read command line arguments, you will need to first declare main
                            function differently:
                            >
                            int main(int argc, char** argv)
                            {
                            >
                            }
                            >
                            Then, use argc and argv parameters to the main function. argc = 1 if
                            no additional parameters are specified on the command line (because
                            "convert" is always the first parameter) 2 if one additional
                            parameters are specified, etc). argv is an array of command line
                            parameters. So, for example say you run the program like this:
                            >
                            $convert 1000p
                            >
                            Then, argc=2 and argv = { "convert", "1000p" }
                            >
                            Good luck.
                            Thank you very much Zachary Turner. I'm going to incorporate command
                            line into my programme. But I want to ask - will the command line
                            options give me more trouble when I'm designing a GUI for this small
                            programme?

                            Comment

                            • mereba

                              #15
                              Re: write small currency converter

                              On Jul 3, 7:09 pm, Zachary Turner <divisorthe...@ gmail.comwrote:
                              On Jul 3, 2:00 pm, mereba <jojoo.imb...@g mail.comwrote:
                              >
                              >
                              >
                              On Jul 3, 5:11 pm, Erik Wikström <Erik-wikst...@telia. comwrote:
                              >
                              On 2007-07-03 17:23, mereba wrote:
                              >
                              On Jul 3, 1:35 pm, "Daniel T." <danie...@earth link.netwrote:
                              mereba <jojoo.imb...@g mail.comwrote:
                              My country Ghana is changing its currency. I want to write a small
                              programme in C++ that can covert from the old currency into the new
                              one. I would like this programme to run behind a simple calculator-
                              looking interface. I'm quite new to C++, and I would need some help.
                              Please any suggestion is welcome :)
                              >
                              Frankly, it sounds like homework. Google, "Ghana currency converter" and
                              you will find dozens of them.
                              >
                              The following is what I have been able to do so far:
                              >
                              #include <iostream>
                              using namespace std;
                              >
                              int main(){
                              //variables declared
                              >
                              int old_currency_va lue, new_currency_va lue, result_of_formu la;
                              >
                              //questions to ask user
                              >
                              cout<< "Please enter the value of the old currency you wish to
                              convert";
                              cin >old_currency_v alue;
                              >
                              //conversion implementation
                              new_currency_va lue = old_currency_va lue/10000;
                              >
                              cout << "The value of the new currency is " << new_currency_va lue <<
                              endl;
                              >
                              //quit programme
                              >
                              return 0;
                              >
                              Your missing the close paren at the end, otherwise your program will
                              compile and run. Is the output what you expected?
                              >
                              This is no joke Daniel T :).My country is CHANGING its currency. I'm
                              not looking for some fancy converters from the old Ghana cedi to US
                              dollars and other currencies. I'm looking to write my own programme
                              that can convert from the old Ghana cedi to the NEW Ghana cedi, andI
                              intend to do just that with C++. Thanks for the tip about closing
                              parentheses. It is well noted. Please more suggestions are welcome.
                              The source code now looks like this:
                              >
                              Looks quite good, there is one problem though, if I input 5000 and
                              500000 I get the same result (50) because you don't tell the user the
                              type of the answer.
                              >
                              Also notice that the variable result_of_formu la is never used so you can
                              delete it. You can also, if you wish, get rid of the variables
                              new_currency_va lue and value_in_pessew as by performing the calculations
                              in the if-statement, like this:
                              >
                              #include <iostream>
                              using namespace std;
                              >
                              int main() {
                              double old;
                              >
                              cout << "Please enter the value of the old currency"
                              "you wish to convert" << endl;
                              cin >old;
                              >
                              if (old < 10000) {
                              cout << "The value of the new currency is "
                              << old / 100 << " pessewas" << endl;
                              }
                              else {
                              cout << "The value if the new currency is "
                              << old / 10000 << " cedi" << endl;
                              }
                              return 0;
                              >
                              }
                              >
                              --
                              Erik Wikström
                              >
                              Many thanks Erik
                              You have given me valuable information. I guess you're right with the
                              50 result. I need to specify which denomination -cedis or pessewas-
                              i'm talking about. True. I'll rewrite the code and make the
                              modifications you have suggested. Thank you very much indeed. Any more
                              suggestions for this small program are welcome.- Hide quoted text -
                              >
                              - Show quoted text -
                              >
                              It would be niec if you could specify command line options. That way
                              no user input is really needed. From your post it looks like either
                              the old or new currency is called "cedis" and the other one is called
                              "pessewas". So, wouldn't it be niec if you could type something like
                              this?
                              >
                              $convert 1000p
                              1000 pessewas is 4705 cedis
                              >
                              $convert 1000c
                              1000 cedis is 200 pessewas
                              >
                              The following inputs might be nice also
                              >
                              $convert
                              Enter the amount to convert: 1000c
                              1000 cedis is 200 pessewas
                              >
                              $convert
                              Enter the amount to convert: 1000
                              1000 pessewas or cedis? p
                              1000 pessewas is 4705 cedis
                              >
                              To read command line arguments, you will need to first declare main
                              function differently:
                              >
                              int main(int argc, char** argv)
                              {
                              >
                              }
                              >
                              Then, use argc and argv parameters to the main function. argc = 1 if
                              no additional parameters are specified on the command line (because
                              "convert" is always the first parameter) 2 if one additional
                              parameters are specified, etc). argv is an array of command line
                              parameters. So, for example say you run the program like this:
                              >
                              $convert 1000p
                              >
                              Then, argc=2 and argv = { "convert", "1000p" }
                              >
                              Good luck.
                              Zachary, is this the right way for me to include the command line
                              options?

                              int main(int argc, char** argv) {

                              argc=2;
                              argv = { "convert", "1000p" };

                              return 0;
                              }

                              Comment

                              Working...