From 7090e0c8ae507f16459f12450c2106a1ab65d021 Mon Sep 17 00:00:00 2001 From: sriv72 <31861735+sriv72@users.noreply.github.com> Date: Thu, 12 Oct 2017 12:21:36 -0500 Subject: [PATCH 1/4] Assignment 4- Pranay Srivastava --- .../Ascending_Descending/Source.cpp | 89 ++++++++++--------- 1 file changed, 45 insertions(+), 44 deletions(-) diff --git a/Three_Digit_Ascending_Descending_Selection/Ascending_Descending/Source.cpp b/Three_Digit_Ascending_Descending_Selection/Ascending_Descending/Source.cpp index 8fb9708..22fccac 100644 --- a/Three_Digit_Ascending_Descending_Selection/Ascending_Descending/Source.cpp +++ b/Three_Digit_Ascending_Descending_Selection/Ascending_Descending/Source.cpp @@ -1,70 +1,71 @@ /* +------------------------------------------------------------------------------------------------------------------------------------------ +OVERALL CHANGES: +Changed spacing between lines of code (so that it is grouped in an easy-to-read format) +Omitted line "cout << x << endl;" as it was unnecessary +Added comments to specific lines in void main() for greater clarification +Added "for" loop to void main() for program to loop 30 times; requirement of assignment +------------------------------------------------------------------------------------------------------------------------------------------ +*/ -Jason Rogers & Cody Ho - 10/12/2017 Period 3 -Assignment Name : Three_Digit_Ascending_Descending_Selection +/* +Your Name - Date Period +Assignment Name : Three_Digit_Ascend_Descend_Selection +Console prints whether digits of 3 digit number input are ascending or descending from left to right -Brief Description of the Assignment : Typing in a 3 digit integer and determining if it is ascending, descending or neither. +ALTERED: Added assignment name, description +(ADD NAME/PERIOD/DATE) */ -// Libraries - -#include // gives access to cin, cout, endl, <<, >>, boolalpha, noboolalpha +// Libraries +#include // gives access to cin, cout, endl, <<, >>, boolalpha, noboolalpha #include // gives access to _kbhit() and _getch() for pause() -// Namespaces +// Namespaces using namespace std; -// Functions() +// Functions() void pause() { - -cout << "Press any key to continue . . ."; - -while (!_kbhit()); - -_getch(); - -cout << '\n'; + cout << "Press any key to continue . . ."; + while (!_kbhit()); + _getch(); + cout << '\n'; } // MAIN - void main() { - - // defining and assigning variables - int x; - int a; + int x; + int a; int b; int c; int y; - cout << "Please enter 3 digit number . . ." << endl; - cin >> x; // generate random 3 digit numbers... ex: '391' - // MAIN - //Defining variables - a = x / 100; - - y = x / 10; - - b = y % 10; - - c = x % 10; - // user queries - cout << x << endl; - if (a > b && b > c) { - cout << "descending" << endl; -} - else if (a < b && b < c) { - cout << "ascending" << endl; + for (int i = 0; i < 30; i++) { // Allows user to input 30 numbers consecutively into program. (ALTERED: req of assignment) + cout << "Please enter any positive 3 digit number . . ." << endl; // ALTERED: added "positive" for greater clarification + cin >> x; // User generates random 3 digit number... ex: '391'. + + a = x / 100; // Define "a" as the 100ths digit of number + y = x / 10; + b = y % 10; // Define "b" as 10ths digit of number + c = x % 10; // Define "c" as ones digit of number + + if (a > b && b > c) { + cout << x << " is descending." << endl; // If the digits of the 3-digit number are decreasing from left to right, print "descending". (ALTERED: added "x is" to statement (req of assignment)) + } + else if (a < b && b < c) { + cout << x << " is ascending." << endl; // If the digits of the 3-digit number are increasing from left to right, print "ascending". (ALTERED: added "x is" to statement (req of assignment)) + } + else { + cout << x << " is neither." << endl; // If the digits of the 3-digit number are neither increasing or decreasing from left to right, print "neither". (ALTERED: added "x is" to statement (req of assignment)) + } + + pause(); // Pauses to see the displayed text. + } } - else { - cout << "neither" << endl; -} - pause(); // pauses to see the displayed text -} From cc618186967b5bf08a32af233669d714ab22f8f7 Mon Sep 17 00:00:00 2001 From: sriv72 <31861735+sriv72@users.noreply.github.com> Date: Thu, 12 Oct 2017 12:23:38 -0500 Subject: [PATCH 2/4] Update Source.cpp --- .../Ascending_Descending/Source.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Three_Digit_Ascending_Descending_Selection/Ascending_Descending/Source.cpp b/Three_Digit_Ascending_Descending_Selection/Ascending_Descending/Source.cpp index 22fccac..6863822 100644 --- a/Three_Digit_Ascending_Descending_Selection/Ascending_Descending/Source.cpp +++ b/Three_Digit_Ascending_Descending_Selection/Ascending_Descending/Source.cpp @@ -10,8 +10,8 @@ Added "for" loop to void main() for program to loop 30 times; requirement of ass /* -Your Name - Date Period -Assignment Name : Three_Digit_Ascend_Descend_Selection +Jason Rogers & Cody Ho - 10/12/2017 Period 3 +Assignment Name : Three_Digit_Ascending_Descending_Selection Console prints whether digits of 3 digit number input are ascending or descending from left to right ALTERED: Added assignment name, description From 9fcedb22af0d9dad0346f64ab4ca77ef00fa7aac Mon Sep 17 00:00:00 2001 From: sriv72 <31861735+sriv72@users.noreply.github.com> Date: Thu, 12 Oct 2017 12:24:19 -0500 Subject: [PATCH 3/4] Update Source.cpp --- .../Ascending_Descending/Source.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Three_Digit_Ascending_Descending_Selection/Ascending_Descending/Source.cpp b/Three_Digit_Ascending_Descending_Selection/Ascending_Descending/Source.cpp index 6863822..706de1d 100644 --- a/Three_Digit_Ascending_Descending_Selection/Ascending_Descending/Source.cpp +++ b/Three_Digit_Ascending_Descending_Selection/Ascending_Descending/Source.cpp @@ -12,11 +12,7 @@ Added "for" loop to void main() for program to loop 30 times; requirement of ass /* Jason Rogers & Cody Ho - 10/12/2017 Period 3 Assignment Name : Three_Digit_Ascending_Descending_Selection -Console prints whether digits of 3 digit number input are ascending or descending from left to right - -ALTERED: Added assignment name, description -(ADD NAME/PERIOD/DATE) - +Brief Description of Assignment: Typing in a 3 digit integer and determining if it is ascending, descending or neither. */ From 41f855155eb32ea7e045226f0c0e4e433242432c Mon Sep 17 00:00:00 2001 From: sriv72 <31861735+sriv72@users.noreply.github.com> Date: Thu, 12 Oct 2017 12:24:41 -0500 Subject: [PATCH 4/4] Update Source.cpp --- .../Ascending_Descending/Source.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Three_Digit_Ascending_Descending_Selection/Ascending_Descending/Source.cpp b/Three_Digit_Ascending_Descending_Selection/Ascending_Descending/Source.cpp index 706de1d..54ffc23 100644 --- a/Three_Digit_Ascending_Descending_Selection/Ascending_Descending/Source.cpp +++ b/Three_Digit_Ascending_Descending_Selection/Ascending_Descending/Source.cpp @@ -12,7 +12,7 @@ Added "for" loop to void main() for program to loop 30 times; requirement of ass /* Jason Rogers & Cody Ho - 10/12/2017 Period 3 Assignment Name : Three_Digit_Ascending_Descending_Selection -Brief Description of Assignment: Typing in a 3 digit integer and determining if it is ascending, descending or neither. +Brief Description of the Assignment: Typing in a 3 digit integer and determining if it is ascending, descending or neither. */