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

Visual Logic Flowchart Help


  • Please log in to reply

#1
creampuff88

creampuff88

    New Member

  • Member
  • Pip
  • 1 posts

Question: Write a program that inputs a number between 1 and 1000 and displays the number with the appropriate two-letter ending (e.g., 1st, 2nd, 3rd, 4th, 5th, 12th, 522nd, 121st). So far I have everything that is needed, but I need help in figuring out proper endings for numbers that end in 1, 2, or 3. So numbers like these will display as so (81st, 82nd, and 83rd). I know there is something to do with MOD and integer division, but it has so far gotten me nowhere. Any help will be much appreciated. Below is what I have for the flowchart as of right now.... 

 

 

Visual_Logic.JPG


  • 0

Advertisements


#2
terry1966

terry1966

    Member 1K

  • Member
  • PipPipPipPip
  • 1,142 posts

it's been decades since i've done any real programming or written a flow chart so no idea if number is the same as &number& in your flow chart but everything looks fine as far as you've gotten.

 

first thing's i'd do is to add in some error checks to make it idiot proof, that way it will work without any unexpected results or errors.

 

start

"please input a whole number from 1 to 1000" number

check number doesn't contain any characters not allowed, letters or decimal points etc.

if yes it does output "sorry only whole numbers from 1 to 1000 allowed, try again" jump back to start.

if no carry on and check number =>1 or =<1000 if no output above message, jump back to start.

if yes carry on and check length of number,

if yes more than a single digit, truncate it to last digit only and then follow your flowchart. (other wise 21st will output 21th with your flowchart.)

if no carry on and follow your flowchart

 

now your flowchart will work with 1 exception numbers ending in 0's, 10,20,etc.

so the first check should be is the number >3 or does the number=0

 

now everything will work and no-one can deliberately or accidentally make your program crash or give an incorrect output.

 

hope that helps you. :D

 

:popcorn:  


Edited by terry1966, 01 May 2015 - 09:41 AM.

  • 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