-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path6controls.cpp
More file actions
46 lines (41 loc) · 1.05 KB
/
Copy path6controls.cpp
File metadata and controls
46 lines (41 loc) · 1.05 KB
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
#include<iostream>
using namespace std;
int main(){
//if-else ladder (sequence structure)
int age;
cout<<"Tell me your age?"<<endl; //Write the cases that you want to be false or banned out (unwanted senarios)
cin>>age;
if ((age<18) && (age>1))
{
cout<<"You cannot come to my party!"<<endl;
}
else if(age==18){
cout<<"You are a kid and you will get a kids pass."<<endl;
}
else if(age<1){
cout<<"You are not yet even born!"<<endl;
}
else if(age>=100){
cout<<"You are probably too old and dead for my party!"<<endl;
}
else
{
cout<<"Welcome to my party!"<<endl;
}
//Switch control (Situation sequence)
switch (age) //The variable and cin condition are created above with the if else ladder
{
case 18:
cout<<"You are 18."<<endl;
break;
case 22:
cout<<"You are 22."<<endl;
break;
case 2:
cout<<"You are 2."<<endl;
default:
cout<<"No special cases for you."<<endl;
break;
}
return 0;
}