aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYana Blashchishina <[email protected]>2024-02-05 22:18:16 -0800
committerYana Blashchishina <[email protected]>2024-02-05 22:18:16 -0800
commit2f6fcc9fa0036cf415d350cbdbf755ae7dd1c690 (patch)
treefbae156391dc3a1c4ea1d623b13b7311b4aaaac2
parentinit (diff)
downloadhomework-4-yanablash-2f6fcc9fa0036cf415d350cbdbf755ae7dd1c690.tar.xz
homework-4-yanablash-2f6fcc9fa0036cf415d350cbdbf755ae7dd1c690.zip
finishedHEADmain
-rw-r--r--Homework4/Homework4/i.program.cpp86
1 files changed, 85 insertions, 1 deletions
diff --git a/Homework4/Homework4/i.program.cpp b/Homework4/Homework4/i.program.cpp
index 06fd3ea..bc211ce 100644
--- a/Homework4/Homework4/i.program.cpp
+++ b/Homework4/Homework4/i.program.cpp
@@ -6,13 +6,97 @@
#include <iostream>
+using std::cout;
+using std::endl;
+using std::cin;
+
+
+
+struct UserDob {
+ int month;
+ int day;
+ int year;
+
+};
+
+void Print100() {
+ for (int i = 0; i <= 100; ++i) {
+ cout << i << ' ';
+ }
+ cout << endl;
+}
+
+UserDob InputInfo() {
+ UserDob userDob;
+ cout << "Enter your birth month: ";
+ cin >> userDob.month;
+
+ cout << "Enter your birthday: ";
+ cin >> userDob.day;
+
+ cout << "Enter your birth year: ";
+ cin >> userDob.year;
+
+ return userDob;
+
+}
+
+
+void PrintFibonacci(size_t n) {
+ int a = 0, b = 1;
+ for (size_t i = 0; i < n; ++i) {
+ cout << a << ' ';
+ int temp = a + b;
+ a = b;
+ b = temp;
+ }
+ cout << endl;
+}
+
int main() {
+ char choice;
+ do {
+ cout << "Menu Options: " << endl;
+ cout << "A. Print100" << endl;
+ cout << "B. Input Info" << endl;
+ cout << "C. Print Fibonacci" << endl;
+ cout << "D. Exit" << endl;
+
+ cout << "Enter your choice: ";
+ cin >> choice;
+
+
+ switch (choice) {
+ case 'A':
+ case 'a':
+ Print100();
+ break;
+ case 'B':
+ case 'b':
+ UserDob userDob = InputInfo();
+ cout << "DOB: " << userDob.month << '/' << userDob.day << '/' << userDob.year << endl;
+ break;
+ case 'C':
+ case 'c':
+ size_t n;
+ cout << "Enter the number of Fibonacci terms: ";
+ cin >> n;
+ PrintFibonacci(n);
+ break;
+ case'D':
+ case'd':
+ cout << "Exiting Program." << endl;
+ break;
+ default:
+ cout << "Invalid. Please try again." << endl;
+ }
+ } while (choice != 'D' && choice != 'd');
return 0;
-} \ No newline at end of file
+}