-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnumerationIntroDEMO.cpp
More file actions
49 lines (39 loc) · 1.33 KB
/
Copy pathEnumerationIntroDEMO.cpp
File metadata and controls
49 lines (39 loc) · 1.33 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
47
48
49
//************************************************************************
// Author: Rolando Carreon
// Date: mar 25 2025
// Language: C++
// Assignment: EnumerationIntroDemo
// Description: Hello World Program
//************************************************************************
#include<iostream>
using namespace std;
// define enumerations // named constant in all caps // ENUM CAN BECOME USER DEF.
// enum in integeral data type
enum Color { RED , GREEN, BLUE, YELLOW, ORANGE};
int main()
{
// declare local variables
Color myColor = RED;
int choice;
Color favoriteColor;
// intro portion
cout << "Color: " << myColor << endl;
if ( myColor == RED )
cout << "The color is red.\n";
else
cout << "The color is NOT red.\n";
// display a menu of colors and ahave the user pick their favourite
cout << "0 - Red\n"
<< "1 - Red\n"
<< "2 - Blue\n"
<< "3 - Yellow\n"
<< "4 - Orange\n"
<< "Select your favorite color: ";
cin >> choice;
// assign a value to the 'favoriteColor' variable
favoriteColor = static_cast<Color>(choice);
// display the value of 'favoriteColor'
cout << "My favorite color is: " << favoriteColor << endl;
// use case statment to convert numbers to names
return 0;
}