-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsentinel.cpp
More file actions
30 lines (25 loc) · 772 Bytes
/
sentinel.cpp
File metadata and controls
30 lines (25 loc) · 772 Bytes
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
// Syeda Umm E Abiha Rizvi
// SE-21014
#include <iostream>
using namespace std;
int main()
{
int month = 1;
float total = 0, rain;
cout << "Enter the total rainfall in inches for month " << month << endl;
cout << "Enter -1 when you are finished" << endl;
cin >> rain;
while (rain != -1)
{
total += rain;
month = ++month;
cout << "Enter the total rainfall in inches for month " << month << endl;
cout << "Enter -1 when you are finished" << endl;
cin >> rain ;
}
if (month == 1)
cout << "No data has been entered" << endl;
else
cout << "The total rainfall for the " << month - 1 << " months is " << total << " inches."<< endl;
return 0;
}