-1

我想做三个项目来计算然后转换

例子:

item1 + item2 + item3 = `total`

然后,转换total为沙特里亚尔

// sss.cpp : 定义控制台应用程序的入口点。//

#include "stdafx.h"
#include "iostream"

int _tmain(int argc, _TCHAR* argv[])
{
    return 0;
}


 using namespace std;
 int main()
 {
 cout << "conver from US dollar to Saudi ryals" << endl;
 double dollars1;
 double dollars2;
 double dollars3;
 double ryals = 3.75;
 cout << "Enter the amount of money you would like to transfer item 1" << endl;
 cin >> dollars1;
 cout << "Enter the amount of money you would like to transfer item 1" << endl;
 cin >> dollars2;
 cout << "Enter the amount of money you would like to transfer item 1" << endl;
 cin >> dollars3;
 cout << "US $" << dollars1 + dollars2 + dollars3 << " equals " << ryals * (dollars1 +        dollars2 + dollars3) << " Saudi ryals." << endl;
 cout << "that's it" << endl;
 cin.get();
 cin.get();
 }
4

1 回答 1

1

今天美元兑沙特里亚尔的汇率是 1 美元兑 3.75 里亚尔。

您的逻辑在这里似乎是正确的:ryals * ( dollars1 + dollars2 + dollars2)但是对于初学者来说,您有两个电源。这在任何情况下都不会发生。另外我会重新考虑你的命名约定dollars1, dollars2, dollars3

#include <stdafx>是由 Visual Studio 自动生成的,这就是为什么我假设为您创建了两个主电源。请参阅此处了解更多信息。

尝试这个:

#include "iostream"

     using namespace std;
     int main()
     {
     cout << "conver from US dollar to Saudi ryals" << endl;
     double dollars1;
     double dollars2;
     double dollars3;
     double ryals = 3.75;
     cout << "Enter the amount of money you would like to transfer item 1" << endl;
     cin >> dollars1;
     cout << "Enter the amount of money you would like to transfer item 1" << endl;
     cin >> dollars2;
     cout << "Enter the amount of money you would like to transfer item 1" << endl;
     cin >> dollars3;
     cout << "US $" << dollars1 + dollars2 + dollars3 << " equals " << ryals * (dollars1 +        dollars2 + dollars3) << " Saudi ryals." << endl;
     cout << "that's it" << endl;
     cin.get();

 }
于 2013-09-10T17:16:31.457 回答