User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 391,666 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,878 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser:
Views: 257 | Replies: 2
Reply
Join Date: May 2008
Posts: 34
Reputation: twgood is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
twgood twgood is offline Offline
Light Poster

Algorithm Verification help please.

  #1  
May 15th, 2008
I am wodering if i answered these correctly or not?
Algorithm Verification

Consider the following selection statement where X is an integer test score between 0 and 100.

input X

if (0 <= X and X < 49)
output "you fail"

else if (50 <= X and X < 70)
output "your grade is" X
output "you did OK"

else if (70 <= X and X < 85)
output "your grade is" X
output "you did well"

else if (85 <= X and X < 100)
output "your grade is" X
output "you did great"

endif
output "how did you do?"


1. What will be printed if the input is 0? You fail
2. What will be printed if the input is 100? Your grade is X you did great
3. What will be printed if the input is 51? Your Grade is you did OK
4. What will be printed if the user enters “Wingding”? how did you do
5. Is this design robust? If so, explain why. If not, explain what you can do to make it robust. No it is not robust; to make it robust there needs to be error messages that are displayed when the wrong integers or strings are imputed.
6. How many levels of nesting are there in this design? 1
7. Give a set of values that will test the normal operation of this program segment. Any set of numbers from 0- 100 will allow this program to operate normally. 1,50,20,32,89,99,45
8. Defend your choices. Any number that is greater than or equal to 0 and less than or equal to 100 will generate a normal operation in this program.
9. Give a set of test values that will cause each of the branches to be executed.
10. Give a set of test values that test the abnormal operation of this program segment. Any number less than 0, such as -1, or any number over 100 such as 101 and anything that is not an integer.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2008
Posts: 345
Reputation: Radical Edward has a spectacular aura about Radical Edward has a spectacular aura about Radical Edward has a spectacular aura about 
Rep Power: 3
Solved Threads: 56
Radical Edward's Avatar
Radical Edward Radical Edward is offline Offline
Posting Whiz

Re: Algorithm Verification help please.

  #2  
May 15th, 2008
> 2. What will be printed if the input is 100? Your grade is X you did great
This answer is not correct. Be sure to carefully check what the boundary number is for each case.

> 4. What will be printed if the user enters “Wingding”? how did you do
This really depends on how the language in question handles input errors of that nature.

> 8. Defend your choices. Any number that is greater than or equal to 0 and less than or equal to 100 will generate a normal operation in this program.
But do your numbers cover all of the cases? Normal operation should take into account any possible valid grade and test that the result is correct. That means covering all of the cases at the least. Edward would suggest the upper and lower boundary for each case.
Last edited by Radical Edward : May 15th, 2008 at 12:38 pm.
If at first you don't succeed, keep on sucking until you do succeed.
Reply With Quote  
Join Date: Feb 2008
Location: Seattle
Posts: 699
Reputation: jephthah is a jewel in the rough jephthah is a jewel in the rough jephthah is a jewel in the rough 
Rep Power: 4
Solved Threads: 45
jephthah's Avatar
jephthah jephthah is offline Offline
Practically a Master Poster

Re: Algorithm Verification help please.

  #3  
May 15th, 2008
>> 4. What will be printed if the user enters “Wingding”?

well .. what happened?? if you used scanf, i'll bet it went to crap real quick. which would not be an example of "robustness".


>> 7. Give a set of values that will test the normal operation of this program segment.

I'm pretty sure they don't want you to say "all values from 0 to 100 are valid" -- i mean, that's obvious; it's in the program specification. And you cant merely go pull values out of the air that "look good"... there needs to be a rationale as to why you pick some but not others.


>> 8. Defend your choices.

so yeah, the point here is NOT to just select all possible values... the point of software testing is that in most every real world application, you just can't reasonably test every possible combination of inputs... you'll likely have the time and resources to only test a small fraction of all possible inputs, so you have to intelligently direct the test cases to exercise some inputs but not others.

at the very least you need to select all the boundary cases, and the numbers on either side of those boundaries. because these are the cases at which typical programming errors occur.


>> 9. Give a set of test values that will cause each of the branches to be executed.

you have 4 cases (branches). pick one representative value from the approximate center of each group. combined with the boundary cases, this would be a reasonable set of test inputs to test the "expected" values, although the boundary case test should exercise each of the groups.


>> 10. Give a set of test values that test the abnormal operation of this program segment. Any number less than 0, such as -1, or any number over 100 such as 101 and anything that is not an integer.

and also non-numerics. such as "ralph" or "15X" or "1,7" etc. this is equally important as the boundary and branch values... testing these "unexpected" input values should be as thorough as possible.


.
Last edited by jephthah : May 15th, 2008 at 8:10 pm.
Why so serious?
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb C Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the C Forum

All times are GMT -4. The time now is 1:49 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC