Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 将美元兑换成欧盟_C++_Algorithm_Converter - Fatal编程技术网

C++ 将美元兑换成欧盟

C++ 将美元兑换成欧盟,c++,algorithm,converter,C++,Algorithm,Converter,我想做三个项目来计算然后转换 例如: item1 + item2 + item3 = `total` 然后,将total转换为沙特里亚尔 //sss.cpp:定义控制台应用程序的入口点。 // #包括“stdafx.h” #包括“iostream” int _tmain(int argc,_TCHAR*argv[] { 返回0; } 使用名称空间std; int main() { cout今天美元对沙特里亚尔的汇率是1美元对3.75里亚尔 你的逻辑在这里似乎是正确的:ryals*(dollar

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

例如:

item1 + item2 + item3 = `total`
然后,将
total
转换为沙特里亚尔

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

#包括“stdafx.h”
#包括“iostream”
int _tmain(int argc,_TCHAR*argv[]
{
返回0;
}
使用名称空间std;
int main()
{

cout今天美元对沙特里亚尔的汇率是1美元对3.75里亚尔

你的逻辑在这里似乎是正确的:
ryals*(dollars1+dollars2+dollars2)
但你首先有两条主线。这在任何情况下都不会发生。而且我认为你的命名惯例是
dollars1,dollars2,dollars3

您的
#include
是由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();

 }
#包括“iostream”
使用名称空间std;
int main()
{

那么,您到底需要帮助解决这个问题的哪一部分?欧元兑瑞尔的乘数是什么?或者如何将三个数字相加?#不包括“”并且扔掉任何向导为您生成的垃圾-为什么有两个主要函数?!在这一个上也很迷茫。但我可以通知您不要将名称空间放在全局范围内。而是使用std::cout、std::endl等。将ryals设为常量,并尽量避免在输出中进行计算。我的意思是多个美元项目来对话您到目前为止尝试了什么?
#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();

 }