From 612dcffbbd97674719146de2304794ff5aab1c2e Mon Sep 17 00:00:00 2001 From: WiserJ Date: Wed, 20 Oct 2021 15:32:23 -0700 Subject: average program v2 --- CST116F2021-Lab4/CST116F2021-Lab4.cpp | 20 +++++++++++--------- 1 file 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 -- cgit v1.2.3