-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.cpp
More file actions
42 lines (33 loc) · 982 Bytes
/
Copy pathfunctions.cpp
File metadata and controls
42 lines (33 loc) · 982 Bytes
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
#include <iostream>
#include <string>
int main() {
std::string name;
int age;
int ageRange;
std::cout << "What is your name? ";
std::getline(std::cin, name);
std::cout << "How old are you? ";
std::cin >> age;
// TODO: Use an if-else to set ageRange based on age
// If age < 13, ageRange = 1 (child)
// Else if age < 20, ageRange = 2 (teen)
// Else ageRange = 3 (adult)
if (age < 13) {
ageRange = 1;
} else if (age < 20) {
ageRange = 2;
} else {
ageRange = 3;
}
// TODO: Print out a message using name and ageRange, for example:
// "Hello, Jacob! You are a teenager."
std::cout << "\nHello, " << name << ".";
if (ageRange == 2) {
std::cout << "You are a teenager.\n";
} else if (ageRange == 1) {
std::cout << "You are a child. \n";
} else {
std::cout << "You are an adult. \n";
}
return 0;
}