Test my program!

Page 3 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.

Gunslinger08

Lifer
Nov 18, 2001
13,234
2
81
Originally posted by: archcommus
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.
Thanks!

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.
 

sao123

Lifer
May 27, 2002
12,653
205
106
Originally posted by: joshsquall
Originally posted by: archcommus
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.
Thanks!

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.



I always solved those problems with case switch blocks...

input x
switch(x)
{
case 1:
do something
case 2:
do something else
default:
illegal input... you screwed up so do it again.
}
handels all difficulties with bad input, case sensitivity, etc.
 

dullard

Elite Member
May 21, 2001
26,060
4,708
126
Originally posted by: archcommus
Can you give me an example of the -0 bug? I tried both 0 and -0 for a few different things and it worked the same both ways.
0 ft, 0 in -> 0 m, 0 cm
-0 ft, -0 in -> 0 m, -0 cm.

I just thought it was funny that it gave a -0 answer. It really isn't a bad problem, just a funny quirk.
 

Gunslinger08

Lifer
Nov 18, 2001
13,234
2
81
Originally posted by: sao123
I always solved those problems with case switch blocks...

input x
switch(x)
{
case 1:
do something
case 2:
do something else
default:
illegal input... you screwed up so do it again.
}
handels all difficulties with bad input, case sensitivity, etc.

That'd be impossible to do in this case. He could use it for the menu, but not where you enter the number of feet/inches/etc. He isn't going to make an infinite option switch statement.
 

sao123

Lifer
May 27, 2002
12,653
205
106
Originally posted by: joshsquall
Originally posted by: sao123
I always solved those problems with case switch blocks...

input x
switch(x)
{
case 1:
do something
case 2:
do something else
default:
illegal input... you screwed up so do it again.
}
handels all difficulties with bad input, case sensitivity, etc.

That'd be impossible to do in this case. He could use it for the menu, but not where you enter the number of feet/inches/etc. He isn't going to make an infinite option switch statement.


no, but vc++ convieniently does offer functions like
template t;
bool isalpha(t value);
bool isnumber(t value);
 

Mark R

Diamond Member
Oct 9, 1999
8,513
16
81
The procedure enry point _encode_pointer could not be located in the dynamic link library MSVCR80.dll

Wow. Helpful error message.
 

SaturnX

Diamond Member
Jul 16, 2000
3,415
0
76
Does not compute.

(On NT4 SP6a)

Crashes on start. Seems I don't have the right DLL....

--Mark
 

Soccerman06

Diamond Member
Jul 29, 2004
5,830
5
81
Are your numbers double float or not? I enter a number thats larger than 2^16 and it creates an infinite loop.
 

archcommus

Diamond Member
Sep 14, 2003
8,115
0
76
Is there anything I can do for the people that don't have the right DLL? As was mentioned earlier, this was compiled with MS VS 2005 and .NET Framework 2.0.

I fixed the H issue. Now if you input ANYTHING other than strictly '1' or '2' it should ask for a new input.

All of my variables are currently of type double, however according to my textbook, doubles should be able to hold numbers from 10^-308 to 10^308, so I'm not sure why 2^16 wouldn't work.

New program is uploaded.
 

sao123

Lifer
May 27, 2002
12,653
205
106
Originally posted by: SaturnX
Does not compute.

(On NT4 SP6a)

Crashes on start. Seems I don't have the right DLL....

--Mark



I dont thing u meet the minimum system requirements...
win 2k sp4 or win xp sp1
.net framework 2.0
 

sao123

Lifer
May 27, 2002
12,653
205
106
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. fixed
2) Quirk: It allows numbers of negative zero to be entered and it treats it different than zero. Imperial to metric conversion... I put in -0, -0 and the result is -0 Meters and 0 centimeters. You should disallow the entry of negative numbers, and you should never have a negative result.
3) Bug: Press Y or N. I press 'H'. Program crashes. Anything but y or Y closes the program... im not sure this is a good behavior. If i miss the y and hit t or u, it pretends that it is a n. you should probably ask for a reinput here.
4) Bug: Enter any number for feet, inches, etc. I press 'H'. Program crashes. still unfixed. Use code posted by joshsquall to fix this
5) Bug: Enter 1e50 feet and 0 inches. Result is -2147483648 meters and 3.048e51 cm. What the heck does that mean? apparently fixed
6) Bug: Enter 1e999 feet. The program enters an endless loop. variable overflow, use similar code posted by joshsquall with exception overflow_error
7) Quirk: Usually, people only want one answer, such as 1.5 meters. They typically don't want 1 meter and 50 cm. specified in the instructions of the assignment
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? fixed
9) Bug: 1 pound is 453.592 grams, NOT 453.597 grams. depends on the significant digits of calculation - ignore
10) Bug: 1 kg is 2 lb and 3.27396 oz, not 2 lb and 3.2736 oz. depends on the significant digits of calculation - ignore

There are probably more problems. But I'm done for now.



Program does not parse numbers of the form, N^X.... You are not parsing your input, you are only storing it in a variable...therefore you must use notation NeX for double types
 

moomoo40moo

Golden Member
Jul 10, 2003
1,449
0
0
works fine now... just tried switching some meters and centimeters to imperial. worked without a hitch...
 

archcommus

Diamond Member
Sep 14, 2003
8,115
0
76
So it seems like the main issue remaining is entering characters instead of numbers for feet, inches, etc. I'm assuming for the scope of this assignment that is okay to leave be.