continue
is for loops, and will not do what you think for the switch.
A better way is to enclose the switch in a while loop controlled with a bool:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
bool Quit = false;
while (!Quit){
switch(choice){
......
case 3: //user wants to quit
Quit = true; //execution continues after the while
break; //could use return or exit function here
default:
}
}
|
@weaver126
You also have global variables - which is bad. Put them in main() and send them to whichever function needs them as references.
When doing math with floating point numbers, explicitly specify them as such, so they don't do integer division - like this:
celsiusTemp=((fahrenheitTemp-32.0f)*5.0f/9.0f);
Personally, I always use doubles - if you specify them as 32.0 say they will default to double. The problem with floats is they only have 7 significant figures of accuracy. This is fine for this assignment, but it doesn't take much for it to be a problem.
Lines 28 - 33 could be a ShowMenu function.
line 35 could be combined into line 33.
With your indentation, line up the closing brace with the first character of the statement that initiated it. For example the brace on line 43 should line up with the i on line 38.
Finally, I like to break bad habits early, so try to avoid having
using neamspace std;
. This brings brings the entire STL into the global namespace, polluting it & causing potential for name clashes.
There are a couple things to do. You can put
std::
before each std thing, or you can do this:
1 2 3 4 5 6
|
using std::cout;
using std::cin;
using std::endl;
using std::string;
using std::vector;
|
I tend to do a mixture, with the above code snippet for things used frequently, and use
std::
for things that are not, such as
std::find
say.
Some guys use
std::
regardless.
HTH