read information entered and display

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//the coding needs to read amount received and donor name until an amount of R0.00 is entered.
//And display the name and donation amount of the donors who donated a R1000.00 or more.

//At the moment it does not compile and does nothing.

#include <iostream>
#include <string>
using namespace std;

int main()
{
string donorName;
float donationAmt = 0.00;
float medicalAmt = 0.00;
float dinigroomAmt = 0.00;

cout<<"Enter Donation Please: ";
cin>>donationAmt;

while (donationAmt > 0.00)
  {
     cin.get();
     getline(cin, donorName, "\n");

  if (donationAmt < 1000.00)
      diningroomAmt += donationAmt; //a = a + b
       else
        {
          medicalAmt += donationAmt;
          cout<<"Donor: "<<donorName<<" Donation amount: "<<donationAmt<<endl;
        }
        cin>>donationAmt;
  }
cout<<"Amount to be used for the medical centre: R"<<medicalAmt<<endl;
cout<<"The amount to be used for dining room furniture: R"<<diningroomAmt<<endl;
  return 0;
}
Last edited on
Topic archived. No new replies allowed.