Results 1 to 3 of 3
  1. #1
    cuse17 is offline Member
    Join Date
    Feb 2009
    Posts
    2
    Rep Power
    0

    Default trouble creating program using loops for multiplication table

    I am currently trying to create a program that displays the multiplication tables from 9 -17 using for loops, do loops, and while loops, I tried to use some suggestions i found for the 0-12 mult. tables but they just confused me more. here is what i have so far... if anyone could please help me fix this or understand what is wrong so that i can at least get case 1 of my switch to work i would greatly appreciate it.


    Java Code:
    import java.io.*;
    
    public class multtble
    {
    
    public static void main(String args[])
    {
    int loop = 5;
    int n = 9, m = 1, i, j;
    
    String t= "";
    System.out.print("type 1 for for loop type 2 for while loop type 3 for do loops ");
    
    BufferedReader stdin1 =new BufferedReader(new
    InputStreamReader(System.in));
    
    {
    try {
    t = stdin1.readLine();
    }catch(java.io.IOException exp){ exp.printStackTrace();}
    
    
    
    loop = Integer.parseInt(t);
    
    System.out.println("");
    }
    
    
    switch(loop){
    case 1:
    
    	for(i = 9; i <18; i++) {
    	for(j = 9; j <18; j++) {
    	System.out.print(n+" ");
    	n +=m;
    	}
    	System.out.println();
    	m++; n = m;}}
    
    	}}

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Cross-posted in Sun forums.

    To the original poster: please do not cross-post questions in multiple forums. This will frustrate anyone who tries to help you only to find out later that the same answer was given hours ago in a cross-posted thread. For this reason, many volunteers here and at the other sites refuse to help repeat offenders.

  3. #3
    cuse17 is offline Member
    Join Date
    Feb 2009
    Posts
    2
    Rep Power
    0

Similar Threads

  1. Creating a SWT table with 1,000,000 items
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 07-11-2008, 05:31 PM
  2. Help combining loops into 1 program.
    By kewlgeye in forum New To Java
    Replies: 5
    Last Post: 04-22-2008, 10:58 AM
  3. trouble with program
    By jimJohnson in forum New To Java
    Replies: 1
    Last Post: 04-03-2008, 10:29 AM
  4. regarding to creating table.....
    By daredavil82 in forum New To Java
    Replies: 0
    Last Post: 11-18-2007, 05:55 AM
  5. Help with multiplication table
    By Albert in forum New To Java
    Replies: 1
    Last Post: 07-10-2007, 05:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •