# Multiplication code

• 12-28-2010, 09:32 AM
bomboy
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
• 12-28-2010, 10:09 AM
eRaaaa
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?
• 12-28-2010, 02:11 PM
Hibernate
Quote:

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
```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);     } }```