Writing code today is a funny thing, write to share with you!

Source: Internet
Author: User
Today, I wrote a short paragraph about the Japanese yen, the euro against the United States dollar exchange rate of the procedure, encountered a very interesting thing, do not want to be happy, send out to share with everyone.
#include <iostream>
#include <string>
using namespace std;
int main ()
{
    const double usd_per_jpy=76.7620;
    const double usd_per_eur=0.7248;
    Double money;
    string symble;
    cout<< "Please input the money by the Symble (JPY/EUR/USD):" <<endl;
    cin>>money>>symble;
    if (symble== "JPY") {
                      cout<<money<< "jpy=" <<money/usd_per_jpy<< "USD" <<endl;
                      }
    else  if (symble== "EUR") {
                             cout<<money<< "eur=" <<money/usd_per_eur<< "USD" < <endl;
                           }
          else {
          cout<< "Sorry, plese check the symble you ' ve input!" <<endl;
              }
              
     System ("pause");
    }


The program runs normally. When you enter 20JPY again, the output

But in the input 10eur, an interesting thing happened, initially thought that their code is wrong, but after several checks, the code is not a problem.

Later, after a meditation, it dawned. Originally in the input 10eur, the computer will 10eur default to 10e ur, so cause error.

Later verified, will be EUR to ur after running again, all normal. It seems that in the future in some of the details still need to pay more attention. But the more I find programming interesting. adhere to ~ ~ ~ Wish everyone happy. Thank you ~ ~ ~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.