-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathex08_b.cpp
More file actions
42 lines (36 loc) · 775 Bytes
/
ex08_b.cpp
File metadata and controls
42 lines (36 loc) · 775 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
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
const int Seasons = 4;
const char *Snames[Seasons] = { "Spring", "Summer", "Fall", "Winter" };
struct sa
{
double expenses[Seasons];
};
void fill(sa *exp);
void show(const sa *exp);
int main()
{
sa exp;
fill(&exp);
show(&exp);
return 0;
}
void fill(sa *exp)
{
using namespace std;
for (int i = 0; i < Seasons; i++)
{
cout << "Enter " << Snames[i] << " expenses: ";
cin >> (*exp).expenses[i];
}
}
void show(const sa *exp)
{
using namespace std;
double total = 0.0;
cout << "\nEXPENSES\n";
for (int i = 0; i < Seasons; i++)
{
cout << Snames[i] << ": $" << (*exp).expenses[i] << endl; total += (*exp).expenses[i];
}
cout << "Total Expenses: $" << total << endl;
}