diff options
| author | WiserJ <[email protected]> | 2021-10-20 15:32:23 -0700 |
|---|---|---|
| committer | WiserJ <[email protected]> | 2021-10-20 15:32:23 -0700 |
| commit | 612dcffbbd97674719146de2304794ff5aab1c2e (patch) | |
| tree | 9f7300edb0a0ff6058e4ca0ce9af3b198a6dfa6c /CST116F2021-Lab4/CST116F2021-Lab4.cpp | |
| parent | average program v1 (diff) | |
| download | cst116-lab4-jeffwoit-612dcffbbd97674719146de2304794ff5aab1c2e.tar.xz cst116-lab4-jeffwoit-612dcffbbd97674719146de2304794ff5aab1c2e.zip | |
average program v2
Diffstat (limited to 'CST116F2021-Lab4/CST116F2021-Lab4.cpp')
| -rw-r--r-- | CST116F2021-Lab4/CST116F2021-Lab4.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/CST116F2021-Lab4/CST116F2021-Lab4.cpp b/CST116F2021-Lab4/CST116F2021-Lab4.cpp index aeb76a3..decdaa0 100644 --- a/CST116F2021-Lab4/CST116F2021-Lab4.cpp +++ b/CST116F2021-Lab4/CST116F2021-Lab4.cpp @@ -22,23 +22,25 @@ int main() float average(int input1, int input2, int input3, float avg) { - cout << "Please input the first value: "; - cin >> input1; - - while (input1 <= 0); + do + { + cout << "Please input the first value: "; + cin >> input1; + } while (input1 <= 0); + + do { cout << "Please input the second value: "; cin >> input2; - } + } while (input2 <= 0); - while (input2 <= 0); + do { cout << "Please input the third value: "; cin >> input3; - } + } while (input3 <= 0); - while (input3 <= 0); - avg = (input1 + input2 + input3)/3; + avg = (input1 + input2 + input3)/3; return avg; }
\ No newline at end of file |