Results 1 to 3 of 3
Thread: Multiplication code
- 12-28-2010, 08:32 AM #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
Thanks for your help
- 12-28-2010, 09:09 AM #2
Senior Member
- Join Date
- Oct 2010
- Location
- Germany
- Posts
- 780
- Rep Power
- 4
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, 01:11 PM #3
- Join Date
- Dec 2010
- Location
- Stockholm, Sweden
- Posts
- 222
- Blog Entries
- 9
- Rep Power
- 3
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); } }
Similar Threads
-
need help with this: multiplication table
By MsIceCold in forum New To JavaReplies: 7Last Post: 07-13-2010, 01:31 PM -
Problem regarding multiplication
By javanewbie1234 in forum New To JavaReplies: 1Last Post: 03-10-2010, 09:27 AM -
Multiplication Table
By SwEeTAcTioN in forum New To JavaReplies: 4Last Post: 02-24-2010, 04:11 AM -
Help with Multiplication
By phil028 in forum New To JavaReplies: 1Last Post: 12-06-2007, 07:39 PM -
Help with multiplication table
By Albert in forum New To JavaReplies: 1Last Post: 07-10-2007, 04:44 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks