Hi everyone, I just want to ask if how i am able to make an if else statement inside a switch case. i want to execute something wherein the user may be able to choose again if he/she would like to do another transaction. for example, the user choose Yes the program will automatically display the main menu option and if the user doesn't want another the program will automatically print "Thankyou for using the program"

Hold up. You want examples in FIVE languages? That's a bit of work so pick one language then supply your coding attempt for all to see what can be done.

Even so, everyone I know heavily discourages any new work in visual-basic-6.

What rproffitt is referring to is that you tagged c++, java, python, javscript, and VB6 when you created this thread. What language are you actually referring to? It might be a case of just being a new user of the site.

That being said, you can do something like this:

if (want to continue)
{
    What do you want to do now?

    switch (options)
    case 1: ...
    case 2: ...
    case 3: ...
}
else
{
    Thank you for playing!
}

Just because you nest it into another structure, doesn't mean the syntax changes. Assuming you are using Java:

Person pers = getRandomPerson(); // assume this exists
char character = pers.getLastName().getCharAt(0);

switch(character) {
  case 'a':
              if ( pers.isAdult()) {
                System.out.println("Person: " + pers.getName() + " is an adult.");
              } else {
                System.out.println("Person: " + pers.getName() + " is a child.");
              }
           break;
  // other cases
}

This is just my opinion and I am not an expert but, rather than writing code inside the switch I think I would rather run out to a sub and do my coding there.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.