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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
|
#include <iostream>
#include <cstring>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cstdlib>
#include <iomanip>
using namespace std;
int main()
{
// Define a new datatype R_Colors and
// the values associated with R_Colors.
enum R_Colors {Black, Brown, Red, Orange, Yellow,
Green, Blue, Purple, Gray, White,
Gold, Silver, None};
R_Colors Band1, Band2, Band3, Band4;
char userChoice;
int Value;
string a;
do {
cout << "\t\t\tResistor's Colors\n"
<< "\tEnter a) Step1: Intialize Band1\n"
<< "\tEnter b) Step2: Intialize Band2\n"
<< "\tEnter c) Step3: Intialize Band3\n"
<< "\tEnter d) Step4: Intialize Band4\n"
<< "\tEnter e) if all steps are complete\n"
<< "\tEnter f) to quit program\n";
cout << "Enter your choice: " << endl;
cin >> userChoice;
switch (userChoice)
{
case 'a':
cout << "Enter the color";
cin >> a;
if (a == "Black")
Band1 = Green;
else if(a == "Brown")
Band1 = Brown;
else if(a == "Red")
Band1 = Red;
else if(a == "Orange")
Band1 = Orange;
else if(a == "Yellow")
Band1 = Yellow;
else if(a == "Blue")
Band1 = Blue;
else if(a == "Purple")
Band1 = Purple;
else if(a == "Gray")
Band1 = Gray;
else
Band1 = White;
//cout << Band1 << endl;
break;
case 'b':
cout << "Enter the color";
cin >> a;
if (a == "Black")
Band2 = Green;
else if(a == "Brown")
Band2 = Brown;
else if(a == "Red")
Band2 = Red;
else if(a == "Orange")
Band2 = Orange;
else if(a == "Yellow")
Band2 = Yellow;
else if(a == "Blue")
Band2 = Blue;
else if(a == "Purple")
Band2 = Purple;
else if(a == "Gray")
Band2 = Gray;
else
Band2 = White;
//cout << Band2 << endl;
break;
case 'c':
cout << "Enter the color";
cin >> a;
if (a == "Black")
Band3 = Green;
else if(a == "Brown")
Band3 = Brown;
else if(a == "Red")
Band3 = Red;
else if(a == "Orange")
Band3 = Orange;
else if(a == "Yellow")
Band3 = Yellow;
else if(a == "Blue")
Band3 = Blue;
else if(a == "Purple")
Band3 = Purple;
else if(a == "Gray")
Band3 = Gray;
else
Band3 = White;
//cout << Band3 << endl;
break;
case 'd':
cout << "Enter the color";
cin >> a;
if (a == "Black")
Band4 = Green;
else if(a == "Brown")
Band4 = Brown;
else if(a == "Red")
Band4 = Red;
else if(a == "Orange")
Band4 = Orange;
else if(a == "Yellow")
Band4 = Yellow;
else if(a == "Blue")
Band4 = Blue;
else if(a == "Purple")
Band4 = Purple;
else if(a == "Gray")
Band4 = Gray;
else
Band4 = White;
//cout << Band4 << endl;
break;
case 'e':
cout << "All Bands have been initialized" << endl;
cout << "Band1 is equal to = " << Band1 << endl;
cout << "Band2 is equal to = " << Band2 << endl;
cout << "Band3 is equal to = " << Band3 << endl;
cout << "Band4 is equal to = " << Band4 << endl;
Value = ((Band1*10)+Band2)*pow(10,Band3);
cout << "The Resistors Value is " << Value << endl;
break;
case 'f':
cout << "Quitting Program" << endl;
return 0;
}
}while (true);
return 0;
}
|