Results 1 to 4 of 4
  1. #1
    rjones215 is offline Member
    Join Date
    Oct 2009
    Posts
    3
    Rep Power
    0

    Default Multiplication table

    This code works the only problem is when the program prompts for input...

    i.e. when you enter 6 the program output should only print out the Multiplication table up to six and not the entire table and it should do this for every number. Please Help






    import java.io.*;
    public class Project4 {

    public static void main(String[] args) throws NumberFormatException, IOException
    {

    BufferedReader in;
    in = new BufferedReader(new InputStreamReader (System.in));
    int numberSelected;
    int output;
    int count = 0;

    System.out.println(" Enter a Number for the");
    System.out.println(" Multiplication Table");
    numberSelected = Integer.parseInt(in.readLine());

    String output1 = "";



    //Print Table body
    for (int i = 1; i <= 9; i++){
    output1 += i + " | ";
    for (int j = 1; j <= 9; j++ ){

    //Display the product and align properly
    count++;
    if (i * j < 10)
    output1 += " " + i * j;
    else
    output1
    += " " + i * j;
    }
    output1 += "\n";
    }

    // Display result
    System.out.println(output1);
    }

    }

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    10

    Default

    Java Code:
    for (int i = 1; i <= 9; i++) {
    How often do you expect this to loop? You never use the input from the user.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  3. #3
    rjones215 is offline Member
    Join Date
    Oct 2009
    Posts
    3
    Rep Power
    0

    Default

    The program should prompt for input infinite times and the input should place a limit on the Multiplication table.

    6 should print out the table up to 6
    8 should print out the table up to 8
    and on and on...

  4. #4
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    10

    Default

    Yes, read my previous post. Care about the multiple outputs for different values later.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

Similar Threads

  1. Replies: 2
    Last Post: 02-23-2009, 03:18 AM
  2. Hash Table help
    By rhm54 in forum New To Java
    Replies: 0
    Last Post: 02-08-2008, 02:25 AM
  3. Help with Multiplication
    By phil028 in forum New To Java
    Replies: 1
    Last Post: 12-06-2007, 08:39 PM
  4. Help with multiplication table
    By Albert in forum New To Java
    Replies: 1
    Last Post: 07-10-2007, 04:44 PM
  5. Table Help
    By CoOlbOyCoOl in forum NetBeans
    Replies: 1
    Last Post: 05-06-2007, 04:19 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
  •