aboutsummaryrefslogtreecommitdiff
path: root/7a/9.3.1Knox/9.3.1Knox.cpp
blob: 96da90aeedef6f3af2f17efa37f246ac91a1e738 (plain) (blame)
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
// 9.3.1Knox.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
using namespace std;

double prompt();

int main()
{
    double avg;
    avg = prompt();

    cout << "The average of the three values is: " << avg << ".";
}

double prompt() 
{
    double sum = 0, value = 0;

    cout << "Input the first value: ";
    cin >> value;
    sum += value;

    cout << "\nInput the second value: ";
    cin >> value;
    sum += value;

    cout << "\nInput the third value: ";
    cin >> value;
    sum += value;

    cout << "\n\n";

    return sum / 3.0;
}