Gunslinger08
Lifer
- Nov 18, 2001
- 13,234
- 2
- 81
Originally posted by: archcommus
Thanks!Originally posted by: dullard
Program now runs.
I'll create a list of bugs/quirks.
1) Bug: Press 1 or 2. I press 'H'. Program goes into an endless loop.
2) Quirk: It allows numbers of negative zero to be entered and it treats it different than zero.
3) Bug: Press Y or N. I press 'H'. Program crashes.
4) Bug: Enter any number for feet, inches, etc. I press 'H'. Program crashes.
5) Bug: Enter 1e50 feet and 0 inches. Result is -2147483648 meters and 3.048e51 cm. What the heck does that mean?
6) Bug: Enter 1e999 feet. The program enters an endless loop.
7) Quirk: Usually, people only want one answer, such as 1.5 meters. They typically don't want 1 meter and 50 cm.
8) Quirk: It asks if I want to run THIS calculation again. I say yes, and it asks which calculation to run. I just answered that I want to run THIS calcuation, so why ask which one? Did you mean to ask if I wanted to run ANOTHER calculation?
9) Bug: 1 pound is 453.592 grams, NOT 453.597 grams.
Okay, well...I'm not sure if I know how to solve the issues of entering characters instead of numbers putting the program into endless loops. As far as reporting "1.5 meters" goes, the spec specifically called to report it like I did. And I will go ahead and reword that last question now.
About that goofy number when you put in a giant number, I have NO idea, maybe because I'm using doubles...
You need to put in error checking. You can use try-catch blocks.
Here's an example:
try
{
Convert.ToDouble(stringNumber);
}
catch (Exception e)
{
cout << "That isn't a number"
}
If an exception occurs when converting/casting, it'll switch into the catch portion. This will solve the 'H' killing your program issue.
