# Multiplication code

• December 28th, 2010, 02:57 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

• December 28th, 2010, 05:27 AM
Freaky Chris
Re: Multiplication code
Firstly welcome to Java Program Forums :)
Secondly, I have moved your post to a more appropriate forum.

Thirdly, what code have you got so far? Better to get stuck in then come to use for help than ask us to do it for you.

You will get good and helpful responses as soon as you post some code that shows you've given it a bash

Thanks,
Chris
• December 28th, 2010, 05:52 AM
goldest
Re: Multiplication code
In case if you are totally chocked up about how to get started, here are some pointers.

1) Use chained stream readers to get the console input.

2) Read the console input into a String.

3) Convert that String into a number using the Integer wrapper class.

4) Have a for loop, get an integer ranging from 2 to 8.

5) Multiply that loop integer with the console number and display the result of each iteration.

Try it out and let us know what have you achieved so far... :-bd

Hope that helps,

Goldest
• December 28th, 2010, 09:46 AM
JavaHater
Re: Multiplication code
Code Java:

```import java.util.Scanner; public class MultiplicationTable { public static void main(String[] args){ int input=0; System.out.print("Enter a number: " ); Scanner keyboard = new Scanner(System.in); ****** fill in the missing code here ******* for(int i=2; i<=8 ; i++){ System.out.println( input + " * " + i + " = " + (input * i) ); } keyboard.close(); } }```
• January 5th, 2011, 01:25 AM
goldest
Re: Multiplication code
This is what I was thinking about,

Code java:

```import java.io.*;   public class MultiplicationTest {   public static void main(String args[]) { System.out.print("Enter Number: "); BufferedReader br = new BufferedReader(new InputStreamReader(System.in));   try { int number = Integer.parseInt(br.readLine()); for (int x = 2; x < 9; x++) { System.out.println(number + " * " + x + " = " + (x * number)); } } catch (IOException io) { io.printStackTrace(); } } }```
Goldest