1. Member
Join Date
Dec 2010
Posts
1
Rep Power
0

## Multiplication code

Hello,
Please i need help in writing code for multiplications of any number by 2 to 8.. I am using Eclipse.
So that when ever you typed a number and hit enter, it will multiply from 2 to 8.

Example: When you type 14 and hit enter after saving and run the code, you get this.
14 x 2 = 28
14 x 3 = 42
14 x 4 = 56
14 x 5 = 70
14 x 6 = 84
14 x 7 = 98
14 x 8 = 112

2. Senior Member
Join Date
Oct 2010
Location
Germany
Posts
787
Rep Power
8
And whats your problem now? Write a for loop from i = 2 to 8(including) and multiply i with the entered number ?
Do you know how to read the user input?

3. Originally Posted by bomboy
Hello,
Please i need help in writing code for multiplications of any number by 2 to 8.. I am using Eclipse.
So that when ever you typed a number and hit enter, it will multiply from 2 to 8.

Example: When you type 14 and hit enter after saving and run the code, you get this.
14 x 2 = 28
14 x 3 = 42
14 x 4 = 56
14 x 5 = 70
14 x 6 = 84
14 x 7 = 98
14 x 8 = 112

Java Code:
```import java.util.Scanner;

public static void main(String[] args)
{
Scanner sc = new Scanner(System.in)
int typed = Integer.parseInt(sc.nextLine());

for (int i = 2; i <= 8; i++)
{
int result = typed * i;
System.out.println(typed + " × " + i + " = " + result);
}
}```