I have to write a seemingly simple code for class that continues to ask for numbers and add them to a running sum until the user wants to stop. When I try to compile it, I get a very long error message that begins:
lab6-part1.cpp: In function ‘int main()’:
lab6-part1.cpp:11: error: no match for ‘operator>>’ in ‘std::cin. std::basic_istream<_CharT, _Traits>::operator>> [with _CharT = char, _Traits = std::char_traits<char>](((double&)(& number))) >> std::endl’
(This is just the first few lines).
It seems to be having trouble with my cin, and I don't understand why. Here's my code.
// Name
// Lab 6, part 1
#include <iostream>
usingnamespace std;
int main ()
{
double choice, number, sum=0;
do {
cout << "How much would you like to add to the sum?";
cin >> number >> endl;
sum = sum + number;
cout << "Would you like to continue (y/n)? ";
cin >> choice >> endl;
} while (choice == 'y');
cout << "The total sum is " << sum << endl;
return 0;
}