More Tutorials| Bioinformatics| Open Source| Photoshop| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Printing Table in JRuby 
 

In the previous sections of JRuby tutorials you have studied how to run program in JRuby and to calculate factorial in JRuby.

 

Printing Table in JRuby

                         

In the previous sections of JRuby tutorials you have studied how to run program in JRuby and to calculate factorial in JRuby. Now in this part of JRuby tutorial we will tell you how to take input in  JRuby from the console and print output table on the console output.

This example to print table will take input from the console and this is being done with the "gets" method. To print table we have used loop control 
"upto...do...end". Here is the example code for generating table in JRuby as follows:

 

 

 

 

JRubyTable.java

# Printing Table in JRuby

print " Enter number to print table := "
n= gets 
1.upto(10) do |i|
puts "#{n} * #{i} = #{n.to_i * i.to_i}"
end

To execute this program execute this JRubyTable.rb with jruby command. This will ask for a value to calculate factorial and generate result according to given value.

Output:

C:\JRuby>jruby JRubyTable.rb
Enter number to print table := 6
6 * 1 = 6
6 * 2 = 12
6 * 3 = 18
6 * 4 = 24
6 * 5 = 30
6 * 6 = 36
6 * 7 = 42
6 * 8 = 48
6 * 9 = 54
6 * 10 = 60

Download Source Code

                         

» View all related tutorials
Related Tags: c ruby ide class ant variables scope classes variable sed const constants jruby name using instance ria this id tar

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.