1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Conditional statement that will prevent users from imputing

  1. Jul 22, 2011 #1
    1. The problem statement, all variables and given/known data

    I was wondering if anyone knows of a conditional statement that will prevent users from imputing non integer inputs.

    like for example
    z=0
    while z<1
    x=input('Enter Something')
    if SOME MAGICAL CONDITIONAL STATEMENT
    disp('You entered a invalid entry. Please try again.')
    else
    z=1;
    end
    end

    I hope you get what I'm trying to do. In a loop prompt a user to enter a number. If the user enters a number like 5.5 I would like the message to come up 'You entered a invalid entry. Please try again.' by using some conditional statement

    anyone got any ideas?

    2. Relevant equations



    3. The attempt at a solution
     
  2. jcsd
  3. Jul 22, 2011 #2

    gneill

    User Avatar

    Staff: Mentor

    Re: solved

    Does the computer language that you're using have INT() or floor() functions?
     
  4. Jul 22, 2011 #3

    SteamKing

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    Re: solved

    It's too bad most programming languages don't have a built-in function which tases users who don't follow directions.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Conditional statement that will prevent users from imputing
  1. IF statement (Replies: 2)

  2. Deadlock Prevention (Replies: 11)

Loading...