Your code is fine, just add the condition to go back to the start of the switch in case no valid case is found, like this:
Quote
start:
cout << " 1 - Air 2 - Water 3 - Steel" << endl;
cin >> medium;
switch(medium){
case 1:
cout << " You have selected air \n" << endl;
cout << " How many feet will the sound wave travel in this medium? \n" << endl;
cin >> distance;
cout << " The total time it will take, in seconds, is " << distance/air << endl;
break;
case 2:
cout << " You have selected water \n" << endl;
cout << " How many feet will the sound wave travel in this medium? \n" << endl;
cin >> distance;
cout << " The total time it will take, in seconds, is " << distance/water << endl;
break;
case 3:
cout << " You have selected steel \n" << endl;
cout << " How many feet will the sound wave travel in this medium? \n" << endl;
cin >> distance;
cout << " The total time it will take, in seconds, is " << distance/steel << endl;
break;
default:
cout << "wrong selection, try again";
goto start;
}
return 0;
}