試撰寫一程式可轉換英哩至公里及轉換公里至英哩的程式,其轉換公

試撰寫一程式可轉換英哩至公里及轉換公里至英哩的程式,其轉換公式如下:

1英哩=1.6公里(C++)請儘快幫我回答感謝喔...

5 Answers

Rating
  • 2 decades ago
    Favorite Answer

    #include<iostream>

    #define transfer 1.69//一英里等於1.69公里,如果我沒記錯的話

    using namespace std;

    int main()

    {

    double d_kilometer=0;//公里

    double d_Mile=0;//英里

    char choice=0;

    cout<<"Which one do you want to transfer?"<<endl

    <<"The Key 1 is for kilometer transfer to Mile"<<endl

    <<"The Key 2 is for Mile transfer to kilometer"<<endl;

    cin>>choice;

    switch(choice)

    {

    case '1':

    cout<<"Please input the value of kilometer"<<endl;

    cin>>d_kilometer;

    cout<<"The value of mile is "<<d_kilometer/transfer<<" Mile"<<endl;

    break;

    case '2':

    cout<<"Please input the value of Mile"<<endl;

    cin>>d_Mile;

    cout<<"The value of kilometer is "<<d_Mile*transfer<<" kilometer"<<endl;

    break;

    }

    return 0;

    }

    以上我執行過了ok! copy後貼到.cpp檔就可執行

    希望以後你自己先想一想問題或參考書中的範例(你應該是C++的初學者吧,不會連書都沒有吧,因為這個問題是所有C書上第一第二章會教的東西,第一個教的當然是 顯示 hellow world!) 上面那幾位大大都在罵你了,不是說問題太簡單,而是這裡不是幫你寫作業的地方,且你的意思"請儘快幫我回答感謝喔... "這樣子說實在不太好,好像人家要聽你命令似的,嗯.......不說那麼多了,你自己想一想吧,有什麼問題再寫信問我吧! 加油!

    Source(s): 自己的腦袋
  • 2 decades ago

    初學者咩...請大家見諒!!

  • 2 decades ago

    ... 倒覺得這裡都快變成問學校功課的地方了說 文字解釋是無妨 但要答案就...

  • Anonymous
    2 decades ago

    來亂很好玩是吧...

    等扣點吧...

  • How do you think about the answers? You can sign in to vote the answer.
  • 2 decades ago

    1000元,附詳細註解,歡迎來函

Still have questions? Get your answers by asking now.