diff options
| author | Connor McDowell <[email protected]> | 2024-02-09 16:28:43 -0800 |
|---|---|---|
| committer | Connor McDowell <[email protected]> | 2024-02-09 16:28:43 -0800 |
| commit | 3ba2c8f72aafeadfaf3731fc684f428dbf29b957 (patch) | |
| tree | edc98d6a394cb69c3d5e0d9898e7ce1a345991cf | |
| parent | working on loops (diff) | |
| download | homework-4-connormcdowell275-3ba2c8f72aafeadfaf3731fc684f428dbf29b957.tar.xz homework-4-connormcdowell275-3ba2c8f72aafeadfaf3731fc684f428dbf29b957.zip | |
finished up! though considering what is practiced this week, i should've tried to do nesting for loops with "error handling" (its not actually, just a conditional to catch improper inputs) for selections, but expecting correct inputs following the messages would mean using if statements wouldrun smoother.HEADmain
| -rw-r--r-- | Project1/Functions.cpp | 33 | ||||
| -rw-r--r-- | Project1/Project1.vcxproj | 1 | ||||
| -rw-r--r-- | Project1/Project1.vcxproj.filters | 3 | ||||
| -rw-r--r-- | Project1/header.h | 2 | ||||
| -rw-r--r-- | Project1/program.cpp | 57 |
5 files changed, 50 insertions, 46 deletions
diff --git a/Project1/Functions.cpp b/Project1/Functions.cpp deleted file mode 100644 index f31aa9f..0000000 --- a/Project1/Functions.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include <iostream> -#include "header.h" - -using std::cout; -using std::cin; -using std::endl; - - -void printUser(userDoB newUser) -{ - cout << "User's birthday is: " << newUser.month << "/" << newUser.day << "/" << newUser.year << endl; -} - -userDoB inputPersonal() -{ - userDoB user = {}; - - cout << "\n Please enter just the day you were born as a number: "; - cin >> user.day; - - cout << "\n Please enter the month you were born as a number: "; - cin >> user.month; - - cout << "\n Now please enter the year you were born as a number: "; - cin >> user.month; - return user; -} - -int Fishonacci() { - cout << "test" << endl; - - return 0; -} diff --git a/Project1/Project1.vcxproj b/Project1/Project1.vcxproj index 72d1ed7..185f904 100644 --- a/Project1/Project1.vcxproj +++ b/Project1/Project1.vcxproj @@ -130,7 +130,6 @@ <ClInclude Include="header.h" /> </ItemGroup> <ItemGroup> - <ClCompile Include="Functions.cpp" /> <ClCompile Include="program.cpp" /> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> diff --git a/Project1/Project1.vcxproj.filters b/Project1/Project1.vcxproj.filters index ad7e65a..f72cfb9 100644 --- a/Project1/Project1.vcxproj.filters +++ b/Project1/Project1.vcxproj.filters @@ -23,8 +23,5 @@ <ClCompile Include="program.cpp"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="Functions.cpp"> - <Filter>Source Files</Filter> - </ClCompile> </ItemGroup> </Project>
\ No newline at end of file diff --git a/Project1/header.h b/Project1/header.h index 60d3344..f842926 100644 --- a/Project1/header.h +++ b/Project1/header.h @@ -2,8 +2,8 @@ #define HEADER struct userDoB { - int month; int day; + int month; int year; }; diff --git a/Project1/program.cpp b/Project1/program.cpp index 3ac38af..3effd14 100644 --- a/Project1/program.cpp +++ b/Project1/program.cpp @@ -10,14 +10,56 @@ using std::cout; using std::cin; using std::endl; -void print100() { +int print100() { int i = 0; while (i < 101) { cout << i << " "; i++; } + if (i == 101) + { + cout << "\n"; + } + return 0; +} + +void printUser(userDoB newUser) +{ + cout << "User's birthday is: " << newUser.month << "/" << newUser.day << "/" << newUser.year << endl; +} + +userDoB inputPersonal() +{ + userDoB user = {}; + + cout << "\n Please enter just the day you were born as a number: "; + cin >> user.day; + + cout << "\n Please enter the month you were born as a number: "; + cin >> user.month; + + cout << "\n Now please enter the year you were born as a number: "; + cin >> user.year; + return user; } +int Fishonacci() { + int n; + cout << "please enter the term you would like to find in the Fibonacci sequence: "; + cin >> n; + + int a = 0, b = 1, c, i; + if (n == 0) + return a; + for (i = 2; i <= n; i++) + { + c = a + b; + a = b; + b = c; + } + cout << "The " << n << "th term in the Fibonacci sequence is: " << b << endl; + return 0; +} int main() { @@ -35,27 +77,26 @@ int main() if (t == 4) { i = 0; } - if (t != 1, 2, 3, 4) { - int main(); - } if (t == 1) { - void print100(); + print100(); + } if (t == 2) { int y; - userDoB inputPersonal(); + userDoB newUser = inputPersonal(); cout << "would you like to print your birthday? enter 1 for yes" << endl; cin >> y; if (y == 1) { - void printUser(); + printUser(newUser); } else { continue; } } if (t == 3) { - int Fishonacci(); + Fishonacci(); } + } |