From b3feaddfb9a469695cd860708ede5b46eabff6a8 Mon Sep 17 00:00:00 2001 From: Xintus Date: Thu, 12 Oct 2017 09:11:16 -0500 Subject: [PATCH] Assignment 4 Changed to add a loop --- Project3/Project3/Source.cpp | 51 ++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/Project3/Project3/Source.cpp b/Project3/Project3/Source.cpp index ae7f746..1c5c11d 100644 --- a/Project3/Project3/Source.cpp +++ b/Project3/Project3/Source.cpp @@ -1,11 +1,8 @@ -/* +/* Ray Chen - Period 1 - Three Digit Ascend Descend Selection - 3 digit number and find stuff about it. - */ // Libraries @@ -17,15 +14,15 @@ Three Digit Ascend Descend Selection using namespace std; //variables -int x; -int A; -int B; -int C; +int x; // number user inputs +int A; // hundreds digit +int B; // tens digit +int C; // ones digit // Functions() void pause() { - cout << "Press any key to continue . . ."; + cout << "Press any key to check another number . . . \n"; while (!_kbhit()); @@ -36,21 +33,23 @@ void pause() { // MAIN void main() { - cout << "Enter a three digit number. \n"; - cin >> x; - -A = (x / 100); -B = (x - A * 100) / 10; -C = (x - A * 100 - (B * 10)); - - if (A < B && B < C) { - cout << "Ascending \n"; - } - else if (A > B && B > C) { - cout << "Descending \n"; + for (int iguess = 0; iguess < 30; iguess = iguess + 1) { + cout << "Enter a three digit number. \n"; + cin >> x; + + A = (x / 100); + B = (x - A * 100) / 10; + C = (x - A * 100 - (B * 10)); + + if (A < B && B < C) { + cout << "Ascending \n"; + } + else if (A > B && B > C) { + cout << "Descending \n"; + } + else { + cout << "Neither \n"; + } + _getch(); // pauses to see the displayed text } - else { - cout << "Neither \n"; - } - pause(); // pauses to see the displayed text -} \ No newline at end of file +}