[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-talk
Subject:    User Input Integers
From:       flebber <flebber.crue () gmail ! com>
Date:       2010-12-22 2:41:56
Message-ID: 60639d5c-7706-480d-9855-9ce3c2ff01b1 () y19g2000prb ! googlegroups ! com
[Download RAW message or body]

using 1.9.1

I have google searched this but there seems to be a very broad array
of answers none very consistent.

Can someone put to bed the exact way to get user input with "Integers"
and specify how many decimals to output too in this case 2 decimals.

Here is a basic program(not working) to calculate netpay.

puts "How many hours did you work?"
hours = gets.chomp()._to.i
puts "What is your tax rate?"
taxrate = gets.chomp()._to.i
tax = (100 - taxrate)
netpay = ((hours * 12.00) *  tax))
puts "Your netpay is, $" $netpay

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic