I'd like to thank you all for your time and help in advanced much appreciated.
Microsoft Visual Studio 2012
C++ Console Application
What my program is to do:
-ask user for value ex. 200 ohms
- output the value in color ex brown black brown
and vice versa
-ask user for color ex brown black brown
-output the value ex 200 ohms
a few background summary:
I'm very new to C++(2 days) i have self taught myself c++ enough to make my very first working program. i got it to output the value based on the color numbers entered. basically am trying to make a resistor color code calculator.
My problem:
- it only outputs the value based on color numbers
how do i make it output value in colors?
- is there better ways of doing this?
Code:#include <iostream> #include <cmath> using namespace std; int main() { double colornum,multiplier; cout<<"0 = black"<<endl; cout<<"1 = brown"<<endl; cout<<"2 = red"<<endl; cout<<"3 = orange"<<endl; cout<<"4 = yellow"<<endl; cout<<"5 = green"<<endl; cout<<"6 = blue"<<endl; cout<<"7 = violet"<<endl; cout<<"8 = grey"<<endl; cout<<"9 = white" <<endl<<endl; cout<<"Enter 1st & 2nd band color numbers: "; cin>>colornum; cout<<"Enter 3rd band color number(Multiplier): "; cin>>multiplier; cout <<"The color code of a "<<colornum<<multiplier<< " resistor is: "; if ( multiplier == 0) { multiplier = colornum * pow( 10,0 ); } else if ( multiplier == 1 ) { multiplier = colornum * pow( 10,1 ); } else if ( multiplier == 2 ) { multiplier = colornum * pow( 10,2 ); } else if ( multiplier == 3 ) { multiplier = colornum * pow( 10,3 ); } else if ( multiplier == 4 ) { multiplier = colornum * pow( 10,4 ); } else if ( multiplier == 5 ) { multiplier = colornum * pow( 10,5 ); } else if ( multiplier == 6 ) { multiplier = colornum * pow( 10,6 ); } else if ( multiplier == 7 ) { multiplier = colornum * pow( 10,7 ); } else if ( multiplier == 8 ) { multiplier = colornum * pow( 10,8 ); } else { multiplier = colornum * pow( 10,9 ); } cout <<multiplier<<endl; return 0; }