We help IT Professionals succeed at work.
Get Started

Promblem with switch  structure in C++

tbeck1982 asked
Last Modified: 2008-01-09
I am having a promblem with a case statement. I am trying to pass an array of letters to this switch statement so that I can assign calues to it. Whenever I try to call the function that has the switch statement
it does nothing and theprogram ends. I would apperciate any advice that can be offered, Below is my code.
using namespace std;

void returnRoman(char roman[]);      
void returnArabic(char roman[], int arabicNum);
void checkInput(char roman[]);

class romanType
      // 0 < num < 3999
      void returnRoman(char roman[16]);                              //Returns a roman numeral
      void returnArabic(char roman[16], int arabicNum);      //Returns a arabic number
      void checkInput(char roman[16]);                              //Checks to see if the roman numeral is in the proper

      int arabicNum; //The variable that stores the arabic number

}; //class romanType

void main()
      int index      = 0;
      int arabicNum = 0;
      char roman[16];
      romanType romanNumeral;

      for(index = 0; index<16; index++)
                  roman[index] = 0;
      cout << "Please enter a roman numeral that you would like to convert." << endl;
      cout << "Make sure that the numerals are in uper-case only." << endl;
      cout << "Enter in the upper-case 'Q' when finished entering numerals." << endl;
index = -1;      

      while(roman[index] != 'Q')
      //romanNumeral.returnArabic(roman, arabicNum);

}//function main

void romanType::checkInput(char roman[])

}//function checkInput

void romanType::returnRoman(char roman[])
      int index = 0;
            for(index = 0; index<16; index++)
            cout << roman[index];

}//function returnRoman

void romanType::returnArabic(char roman[], int arabicNum)
      int index = 0;
      int value = 0;
while(roman[index] != 'Q')
      switch (roman[index])
                          case 'M': case 'm':
                              value = 1000;
                  case 'D': case 'd':
                              value = 500;
                  case 'C': case 'c':
                              value = 100;
                  case 'L': case 'l':
                              value = 50;
                  case 'X': case 'x':
                              value = 10;
                  case 'V': case 'v':
                              value = 5;
                  case 'I': case 'i':
                              value = 1;
                        arabicNum = value + arabicNum;
      }//end of switch structure
}//end of while loop

cout << arabicNum << endl;
}//function returnArabic

Watch Question
Top Expert 2009
This problem has been solved!
Unlock 3 Answers and 6 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE