3 Replies - 713 Views - Last Post: 21 September 2010 - 03:04 PM Rate Topic: -----

#1 ahbrahim2  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 58
  • Joined: 21-September 09

How to read an input value that is a decimal

Posted 21 September 2010 - 12:29 PM

I'm trying to calculate a area. and whant to read an ipnut for the radius from the user, but it has to bee only two decimal place. How can I know the input is two or more decimla. and if the user enter an number that is more than two decimal it has throw and error and reprompt the user to enter again but it does have to be exeption handling.
Thanks for nay help.

This post has been edited by ahbrahim2: 21 September 2010 - 12:31 PM

Is This A Good Question/Topic? 0
  • +

Replies To: How to read an input value that is a decimal

#2 Salem_c  Icon User is offline

  • void main'ers are DOOMED
  • member icon

Reputation: 1706
  • View blog
  • Posts: 3,268
  • Joined: 30-May 10

Re: How to read an input value that is a decimal

Posted 21 September 2010 - 01:13 PM

- read it as a string
- make sure the decimal point is in the right place
- and convert.
Was This Post Helpful? 0
  • +
  • -

#3 Manipulate  Icon User is offline

  • New D.I.C Head

Reputation: 7
  • View blog
  • Posts: 38
  • Joined: 21-July 10

Re: How to read an input value that is a decimal

Posted 21 September 2010 - 01:56 PM

What he said. Just put that inside a verification loop and you should be golden.
Was This Post Helpful? 0
  • +
  • -

#4 ahbrahim2  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 58
  • Joined: 21-September 09

Re: How to read an input value that is a decimal

Posted 21 September 2010 - 03:04 PM

View PostManipulate, on 21 September 2010 - 12:56 PM, said:

What he said. Just put that inside a verification loop and you should be golden.

[quote]Thanks for your help[/qute]
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1