Results 1 to 3 of 3
  1. #1
    bomboy is offline Member
    Join Date
    Dec 2010
    Posts
    1
    Rep Power
    0

    Default 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

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    6

    Default

    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. #3
    Hibernate's Avatar
    Hibernate is offline Senior Member
    Join Date
    Dec 2010
    Location
    Stockholm, Sweden
    Posts
    222
    Blog Entries
    9
    Rep Power
    5

    Default

    Quote Originally Posted by bomboy View Post
    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

    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

  1. need help with this: multiplication table
    By MsIceCold in forum New To Java
    Replies: 7
    Last Post: 07-13-2010, 02:31 PM
  2. Problem regarding multiplication
    By javanewbie1234 in forum New To Java
    Replies: 1
    Last Post: 03-10-2010, 10:27 AM
  3. Multiplication Table
    By SwEeTAcTioN in forum New To Java
    Replies: 4
    Last Post: 02-24-2010, 05:11 AM
  4. Help with Multiplication
    By phil028 in forum New To Java
    Replies: 1
    Last Post: 12-06-2007, 08:39 PM
  5. Help with multiplication table
    By Albert in forum New To Java
    Replies: 1
    Last Post: 07-10-2007, 05:44 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •