From 2c3347ad44f82d8db2d78b48a05e8ab5e61b15be Mon Sep 17 00:00:00 2001 From: austinsworld15 <91639488+austinsworld15@users.noreply.github.com> Date: Tue, 19 Oct 2021 18:59:06 -0700 Subject: Update CST116F2021-Lab3-Guertin.cpp --- CST116F2021-Lab3/CST116F2021-Lab3-Guertin.cpp | 47 +++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'CST116F2021-Lab3/CST116F2021-Lab3-Guertin.cpp') diff --git a/CST116F2021-Lab3/CST116F2021-Lab3-Guertin.cpp b/CST116F2021-Lab3/CST116F2021-Lab3-Guertin.cpp index 1074279..10aa010 100644 --- a/CST116F2021-Lab3/CST116F2021-Lab3-Guertin.cpp +++ b/CST116F2021-Lab3/CST116F2021-Lab3-Guertin.cpp @@ -302,4 +302,51 @@ int main() 1. +#include +#include +#include +#include +#include +using std::cout; +using std::endl; +using std::string; + +int main() +{ + int count; + int converted_to_even; + + + cout << "Input any number between 1 and 50:\n\n"; + std::cin >> count; + + + if (count >= 1 && count <= 50) + { + cout << "\n\nCounting down the even numbers to 0:\n\n"; + } + else + do { + cout << "\n\nERROR, this number is not between 1 and 50, please enter a number between 1 and 50\n\n"; + std::cin >> count; + } + + while (count > 50 || count < 1); + + + if (count % 2 == 1) + { + converted_to_even = count - 1; + } + else + { + converted_to_even = count; + } + + while (converted_to_even >= 0) + { + cout << converted_to_even << endl; + converted_to_even -= 2; + } +} -- cgit v1.2.3