aboutsummaryrefslogtreecommitdiff
path: root/Project1/program.cpp
blob: 3effd14504ba8f83a4cec6197e8a0276e2998e0c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// Name: Connor McDowell
// date: 2/9/2024
// class: CST116
// assignment: Assignment 4 (homework)

#include <iostream>
#include "header.h"

using std::cout;
using std::cin;
using std::endl;

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()
{
	int i = 1;
	while (i == 1) {
		int t = 0;
		cout << "Hello and welcome to the selection menu for Connor McDowell's CST116 homework assignment number 4" << endl;
		cout << "Please enter a number from the selection below" << endl;
		cout << "1: Print all integers from 0 to 100" << endl;
		cout << "2: Input date of birth" << endl;
		cout << "3: print the Fibonacci sequence up to an inputted term" << endl;
		cout << "4: Exit the program" << endl;
		cout << "Else will re-print this message!" << endl;
		cin >> t;
		if (t == 4) {
			i = 0;
		}
		if (t == 1) {
			print100();
			
		}
		if (t == 2) {
			int y;
			userDoB newUser = inputPersonal();
			cout << "would you like to print your birthday? enter 1 for yes" << endl;
			cin >> y;
			if (y == 1) {
				printUser(newUser);
			}
			else {
				continue;
			}
		}
		if (t == 3) {
			Fishonacci();
		}
		
	}
	
	
	
	//userDoB newUser = inputPersonal();

}