Here is my code : Code for main function:
switch(ch){
case 1:{
// Call the function two times to store the result from color function
b = color(BAND_COLOR_CODE, band);
c = color(BAND_COLOR_CODE, band);
cout << "\n";
//Call the function to store the result from the calculation
---------code here------
//Call the function to store the tolerance
-------code here-------
------code---------
else{
//Display information about the resistor
cout << "Results:\n" << "R="<<product << "ohms \n" <<"Tolerance=" <<output <<"%\n"<<"Rmax="<<x<<"\nRmin="<<y<< endl;
cout << "\n";
}
break;
}
Code snippet for color function
int color(string BAND_COLOR_CODE[], const int band)
{
static int j = 64; // Stores user input for color
int i=0;
++j; // Increments to allow user to input colors in succession
// Prompt for user input
cout << "Please enter a color for band " << (char)j << ": >";
cin.getline(code,10);
cout<<"\n";
// Loop to take care of the case of letters
-----------
----------code here------
-----code here-----
}
So basically in my switch case i am calling the function color() two times but as you can see that i am unable to give input on my output screen as the function prints Please enter a color for band A:> Please enter a color for band B:> simultaneously without allowing me to give the input for band A . though i am able to give the input for band b. I don't understand the reason for this anomaly in my code Please help.