我想要制作三个项目然后转换
示例:
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();
}
答案 0 :(得分:1)
今天美元兑沙特里亚尔的汇率为1美元兑3.75里亚尔。
你的逻辑在这里似乎是正确的:ryals * ( dollars1 + dollars2 + dollars2)
但是对于初学者你有两个主管。在任何情况下都不会发生这种情况。另外,我会重新考虑dollars1, dollars2, dollars3
您的#include <stdafx>
是由Visual Studio自动生成的,这就是为什么我假设为您创建了两个主电源。有关详细信息,请参阅here。
试试这个:
#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();
}