Results 1 to 2 of 2
Thread: Addition Table?
- 10-24-2012, 02:57 AM #1
Member
- Join Date
- Oct 2012
- Posts
- 37
- Rep Power
- 0
Addition Table?
This is the code for an addition table I made for my class. This prints the table properly, but the teacher said "Your printAdditionTable is printing the whole table itself instead of using a method to do a row and then repeating that method (that row) with a different starting value." I think I need to do a loop, but dont know how would I do this. any help would be appreciated.
Java Code:public static void printAddTable (){ int i = 0, j=0; for (i=0; i<=12; i++) { for (j=0; j<=12; j++){ System.out.print (i+j+ " "); } System.out.println (" "); } }
- 10-24-2012, 03:04 AM #2
Senior Member
- Join Date
- Oct 2012
- Posts
- 108
- Rep Power
- 0
Re: Addition Table?
Something like this for printing a row at a time. You've got the right idea to begin with, just need to create a method to do it.Java Code:public static void printRow(int i, int max){ for(int j = 0; j<=max; j++){ System.out.print(i + j + "\t"); /Print entry plus tab char. } System.out.println(); }
Similar Threads
-
Need help with Addition Calculator!
By Laon8orsSon in forum New To JavaReplies: 4Last Post: 05-24-2012, 11:27 AM -
addition
By rithish in forum New To JavaReplies: 4Last Post: 10-04-2011, 08:15 AM -
Addition of Two time
By jithan in forum New To JavaReplies: 5Last Post: 12-29-2008, 11:09 AM -
Addition Problem
By tornado in forum New To JavaReplies: 6Last Post: 12-06-2008, 11:37 PM -
string addition??
By j2vdk in forum New To JavaReplies: 2Last Post: 09-03-2008, 03:41 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks