/***************************************************************
* Name: Prof. Rafael Orta
* Course: Computer Science & Programming
* Class: CS04103 Section: 1 & 2
* Assignment Date: 09/24/20
* File Name: Chapter4.cpp
*****************************************************************
* ID: Chapter 4
* Purpose: To demonstrate some of the concepts covered in chapter 4
*****************************************************************/
#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
// variable declaration
int age;
char grade;
char character = '1';
/*
// ------------- Using funtions to test characters. ---------------
if (isalpha(character))
cout << "Is alphabetical";
else
cout << "Is not alphabetical";
return 0;
*/
// ---------------------- Nested if example -----------------------
// Collecting Input
cout << "Please insert your age: ";
cin >> age;
// Input evaluation & display of results
if (age < 16)
cout << "Sorry you need to grow a bit more..";
else if (age >= 16 and age <21)
cout << "Congratulations you can drive..";
else if (age >= 21 and age <=24)
cout << "Congratulations you can drink, but with moderation";
else
cout << "Sorry the fun is over, time to get a job!!!";
// ---------------------- Switch Example ---------------------------------
/*
cout << "Please insert your grade: ";
cin >> grade;
switch(grade) {
case 'A' :
cout << "Excellent!" << endl;
break;
case 'B' :
case 'C' :
cout << "Well done" << endl;
break;
case 'D' :
cout << "You passed" << endl;
break;
case 'F' :
cout << "Better try again" << endl;
break;
default :
cout << "Invalid grade" << endl;
}
cout << "Your grade is " << grade << endl;
// ---------------------- Enumerator Example ---------------------------------
enum week { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday };
week today;
today = Thursday;
cout << "Day " << today;
*/
return 0;
}