The result should be:
Accepting donations till we reach $100
Enter donation, or zero for no donation: 12
Enter donation, or zero for no donation: 10
Enter donation, or zero for no donation: 15
Enter donation, or zero for no donation: 0
Enter donation, or zero for no donation: 18
Enter donation, or zero for no donation: 0
Enter donation, or zero for no donation: 20
Enter donation, or zero for no donation: 27
Total amount donated: $102.00
Number of donors: 6
Average donation: $17.00
What I have so far: I'm looking for examples to compare - if that makes sense
------------
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
#include <iostream>
using namespace std;
int main()
{
int donation;
double sum = 0;
while (sum < 100)
{
cout << "Enter donation or zero for none: ";
cin >> donation;
cout << "Sum of Donation: " << sum << endl;
sum += donation;
}
system("pause");
return 0;
}
|