I am to make a program that finds the value of a resistor after inputting 3 letters those letters of are of the color on the resistor. i have written a program to do so but the value does not follow the equation. I am not sure if the program is not running because i am not used to writing programs using functions
p.s. sry if the program does not come out correct when i post
#include <iostream>
#include <cmath>
using namespace std;
int cResist(int,int,int);
int cCode(int);
int CC(int);
int c1,c2,c3;
double val;
int main(){
cout<<"Color code""\t""Character code"<<endl;
cout<<"Black""\t""B""\t""0"<<endl;
cout<<"Brown""\t""N""\t""1"<<endl;
cout<<"Red""\t""R""\t""2"<<endl;
cout<<"Orange""\t""O""\t""3"<<endl;
cout<<"Yellow""\t""Y""\t""4"<<endl;
cout<<"Green""\t""G""\t""5"<<endl;
cout<<"Blue""\t""E""\t""6"<<endl;
cout<<"Violet""\t""V""\t""7"<<endl;
cout<<"Gray""\t""A""\t""8"<<endl;
cout<<"White""\t""W""\t""9"<<endl;
char c1,c2,c3;
cout<<"input the first letter of the color:";cin>>c1;
cout<<"input the second letter of the color:";cin>>c2;
cout<<"input the third letter of the color:";cin>>c3;
val=cResist(c1,c2,c3);
cout<<val<<endl;
return 0;
}
int cResist(int c1,int c2, int c3){
int val1,val2,val3;
val1=cCode(c1);
val2=cCode(c2);
val3=cCode(c3);
val=(10.0*val1+val2)*(pow(10.0,val3));
return val;
}
int cCode(int CC){
switch(CC){
case 'B':0;break;
case 'N':1;break;
case 'R':2;break;
case 'O':3;break;
case 'Y':4;break;
case 'G':5;break;
case 'E':6;break;
case 'V':7;break;
case 'A':8;break;
case 'W':9;break;
}
return CC;
}