Using a for loop, I have wrote a program that displays a “6 times table” multiplication table:
public class TimesTable3_4a
public static void main(String args)
int table = 6;
for ( int row=1; row<=12; row++ )
System.out.println( row + " * " + table + " = " +
( table * row ) );
How could I adapt the above program so that instead of a “6 times” table, the user chooses which table is displayed?
Thanks in advance.
the user can gice the program info in the following way:
java TimesTable3_4a 6
This would give a 6 to the application.
Parameters passed to applications in such a way end up in the String args variable.
(order in wich they appear is the same as wich they were entered on command line.
This should send you in the right way...
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL