/* Craig Persiko - CS 110A
BooleanApp.cpp
Demonstrates use of Boolean variables and multi-way if statements.
*/
#include <iostream>
using namespace std;
int main()
{
int age;
bool workingAge;
cout << "Please enter your age\n";
cin >> age;
if(age < 13)
{
cout << "You're a child\n";
workingAge = false; // this line is unnecessary because
// workingAge is set below, but instead
// of that line, lines like this could be
// added after each output below.
}
else if(age < 18)
cout << "You're a teenager\n";
else if(age < 65)
cout << "You're a working adult\n";
else
cout << "You're a retiree\n";
workingAge = age < 65 && age >= 18;
if (workingAge)
cout << "Want a job?\n";
}
/* Sample output:
Please enter your age
5
You're a child
Please enter your age
31
You're a working adult
Want a job?
Please enter your age
70
You're a retiree
Please enter your age
16
You're a teenager
*/
syntax highlighted by Code2HTML, v. 0.9