From: Saji Hameed Date: 2012-02-09T13:39:36+09:00 Subject: Re: Student needs help with simple loop. hope that some thing like the following may work for you. n1, n2 = 0, 0 while n1==0 do puts " n1 = " n1=gets.chomp.to_i end while n2==0 do puts " n2 = " n2=gets.chomp.to_i end puts "you are finsihed" saji On Thu, Feb 9, 2012 at 1:17 PM, Clay Tzoucalis wrote: > So I have to create a ruby file for class that asks the individual to > enter two numbers, which are then put into equations to provide the > addition, subtraction, multiplication, and division. The trouble I am > having is when the individual is asked to enter their number they are > supposed to be unable to enter 0 as a number and if they do it is > supposed to loop them back to the original question. I can not figure > out how to do this correctly. Below is my file, so if anyone can show > and inform me how this is done I would GREATLY appreciate it. > > > class NumberCruncher >  class Screen > >      def cls >        puts ("\n" * 25) >      end >  end > >  Console_Screen = Screen.new > >  Console_Screen.cls > >    puts "Please enter a number now. (Press Enter)" >       number1 = STDIN.gets >       number1.chomp! > > >  puts "Please enter a new number now. (Press Enter)" >        number2 = STDIN.gets >        number2.chomp! > >   Console_Screen.cls > >  print "Added first and second number.\n" , (number1.to_i + > number2.to_i) >   pause = STDIN.gets >  Console_Screen.cls > >  print "Subtracted second from first number.\n" , (number1.to_i - > number2.to_i) >   pause = STDIN.gets >  Console_Screen.cls > >  print "Multiplied first and second number.\n" , (number1.to_i * > number2.to_i) >   pause = STDIN.gets >  Console_Screen.cls > >  print "Divided first by second number.\n" , (number1.to_i / > number2.to_i) >   pause = STDIN.gets >  Console_Screen.cls > >  puts "You're finished!" >  end > > -- > Posted via http://www.ruby-forum.com/. > -- Saji N Hameed, ARC-ENV, Center for Advanced Information Science and Technology, University of Aizu, Tsuruga, Ikki-machi, Aizuwakamatsu-shi, Fukushima 965-8580, Japan Tel: +81242 37-2736 Fax:+81242 37-2760  email: saji@u-aizu.ac.jp  url: http://www.u-aizu.ac.jp  bib: http://www.researcherid.com/rid/B-9188-2009