Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
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