<分区>
我不断收到此错误消息:
exit status 1
main.cpp: In function 'int main()':
main.cpp:31:68: error: unable to find string literal operator 'operator""endl'
with 'const char [3]', 'long unsigned int' arguments
At cout<< "The total purchase value amount is ">>totalPurchase<<"$."endl;
抱歉,我是编程新手,我不知道如何解决这个问题,我知道这很简单。我只是想得到一个$。当数据打印给用户时,在我的值后面,因此它看起来格式很好。对我做错了什么的任何解释将不胜感激。 如果我删除“$”。部分它工作得很好,但它向用户显示的只是一个数字,而不是美元值(value)。
感谢您的帮助!
#include <iostream>
#include <string>
using namespace std;
int main() {
//The part is to declare our constants and variables
double totalPurchase;
double calcstatetax;
double calccountytax;
double totalsalestax;
double ultimatevalue;
double statetax = .04;
double countytax = .02;
//This part is to allow the user to input information
cout << "Enter the amount of the purchase.";
cin >> totalPurchase;
//This part is our algorithm calculating the needed values
calcstatetax = totalPurchase*statetax;
calccountytax = totalPurchase*countytax;
totalsalestax = calcstatetax+ calccountytax;
ultimatevalue = totalsalestax+ totalPurchase;
//This part displayes our calculated values to the user.
cout<< "The total purchase value amount is "<<totalPurchase<<"$."endl;
cout<< "The calculated state tax is "<<calcstatetax<<endl;
cout<< "The calculated county tax is "<<calccountytax<<endl;
cout<< "The total sales tax is "<<totalsalestax<<endl;
cout<< "The total value of the purchase including the combined sales tax is "<<ultimatevalue<<endl;