Hello to all the Readers ,

I am trying to create a Multi-Table from 10 Numbers given by a user.
I cant figure it out why the Multitable isnt shown correctly. I tried
to enter the 1-10 numbers to get the result we all know and still nothing good came out.

thank you for you help , Code is Attached . :)

Yotam , Israel.

Recommended Answers

All 5 Replies

Member Avatar for iamthwee
* 
 */
import java.util.Scanner;

/**
 * @author Yotam Golomb ID 040435497
 *
 */
public class MultiTableProg {

	
	/**
	 * @param args
	 */
	public static void main(String[] args) 
	{
		// TODO Auto-generated method stub
		Scanner input=new Scanner(System.in);
		int temp;
		int sum=1;
		System.out.println("Welcome to HomeWork 1.");
		System.out.println("Please Enter 10 Numbers , Range 1 to 50");
		
		for (int i=1;i<11;i++)
		{
			temp=input.nextInt();
			for (int j=1;j<11;j++)
			{
			
			System.out.printf("\t%d",sum*temp);
			sum=temp;
			}
		System.out.printf("\n");
		
		}
		
		
		
	}

}

What do u expect the code to do?

* 
 */
import java.util.Scanner;

/**
 * @author Yotam Golomb ID 040435497
 *
 */
public class MultiTableProg {

	
	/**
	 * @param args
	 */
	public static void main(String[] args) 
	{
		// TODO Auto-generated method stub
		Scanner input=new Scanner(System.in);
		int temp;
		int sum=1;
		System.out.println("Welcome to HomeWork 1.");
		System.out.println("Please Enter 10 Numbers , Range 1 to 50");
		
		for (int i=1;i<11;i++)
		{
			temp=input.nextInt();
			for (int j=1;j<11;j++)
			{
			
			System.out.printf("\t%d",sum*temp);
			sum=temp;
			}
		System.out.printf("\n");
		
		}
		
		
		
	}

}

What do u expect the code to do?

Well , i.e. :
if the input is numbers from 1 to 10 :
1 2 3 4 5 6 7 8 9 10
2 4 ...................20
3 6....................30
4 8....................40
5 10 .
6 12 .
7 14 .
8 16 .
9 18 .
10 20............... 100

I hope the Example is helpful.

thanx again , Yotam

Member Avatar for iamthwee
int start = 1;
  int max = 10;

    for ( int k = start; k < max + 1; k++ )
    {
        System.out.print( k + "\t");
    }
    System.out.print( "\n");
    
    for ( int i = start+1; i < max + 1; i++ )
    {
        System.out.print( i + "\t");
        for ( int j = start+1; j < max + 1; j++)
        {
            System.out.print (i * j + "\t");
        }System.out.print("\n");
    }

My output:

1       2       3       4       5       6       7       8       9       10

2       4       6       8       10      12      14      16      18      20

3       6       9       12      15      18      21      24      27      30

4       8       12      16      20      24      28      32      36      40

5       10      15      20      25      30      35      40      45      50

6       12      18      24      30      36      42      48      54      60

7       14      21      28      35      42      49      56      63      70

8       16      24      32      40      48      56      64      72      80

9       18      27      36      45      54      63      72      81      90

10      20      30      40      50      60      70      80      90      100

That should work

int start = 1;
  int max = 10;

    for ( int i = start; i < max + 1; i++ )
    {
        for ( int j = start; j < max + 1; j++)
        {
            system.out.print ( i * j + "\t%d");
        }
         system.out.println("");
    }

My output:

1       2       3       4       5       6       7       8       9       10

2       4       6       8       10      12      14      16      18      20

3       6       9       12      15      18      21      24      27      30

4       8       12      16      20      24      28      32      36      40

5       10      15      20      25      30      35      40      45      50

6       12      18      24      30      36      42      48      54      60

7       14      21      28      35      42      49      56      63      70

8       16      24      32      40      48      56      64      72      80

9       18      27      36      45      54      63      72      81      90

10      20      30      40      50      60      70      80      90      100

Actually that don't work oops.

I wish to get 10 numbers from User and store them somehow without an array for that matter and get the same MultiTable to those numbers.
Its very tricky , i tried using some sort of SUM Varieble but couldnt make it work

Member Avatar for iamthwee

I wish to get 10 numbers from User and store them somehow without an array for that matter and get the same MultiTable to those numbers.
Its very tricky , i tried using some sort of SUM Varieble but couldnt make it work

See my just edited program

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.