Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

question about algorithms


  • Please log in to reply

#1
lynnajoe

lynnajoe

    New Member

  • Member
  • Pip
  • 5 posts
Hi,

I have a question about an algorithm. If an entry that is inputted is outside the parameters of an algorithm, does an error message show?

Here is the algorithm. Please be patient as I am quite new to this. This seems easy to me and I have already been graded on this Appendix. 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?"

If the input is 0 then what would the output be? I thought it would be "you fail" and nothing else. Also if the input is 100, this does not seem to be set up properly for the number 100 so I thought the result would be an error message maybe invalid entry. Can someone help me as I am in constant conflict with this instructor over everything.

Thank you,

Lynnajoe

Edited by Essexboy, 02 August 2010 - 01:10 PM.
e-mail removed

  • 0

Advertisements


#2
victor!

victor!

    New Member

  • Member
  • Pip
  • 4 posts
Hi.
With just that piece of code no error message would show if input X failed to match any of the conditions. For this to happen you would have to create a error message to be displayed. As for the input being 0 or 100, if 0 was your input then the output will be "you fail" and only that, since the condition for this is 0 <= X. But in the case of X being 100, no output regarding it would show since the condition in the last if is X < 100. To solve this just simple change the last if condition to X <= 100.

Best of luck,
Victor.
  • 0

#3
lynnajoe

lynnajoe

    New Member

  • Topic Starter
  • Member
  • Pip
  • 5 posts

Hi.
With just that piece of code no error message would show if input X failed to match any of the conditions. For this to happen you would have to create a error message to be displayed. As for the input being 0 or 100, if 0 was your input then the output will be "you fail" and only that, since the condition for this is 0 <= X. But in the case of X being 100, no output regarding it would show since the condition in the last if is X < 100. To solve this just simple change the last if condition to X <= 100.

Best of luck,
Victor.


  • 0

#4
lynnajoe

lynnajoe

    New Member

  • Topic Starter
  • Member
  • Pip
  • 5 posts
Hi,

Thank you for your help-I really appreciate it. Also thank you to essexboy for editing my post.

lynnajoe
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP