0

Hi DaniWeb members:),

I hope we could discuss about this matter and please do give advise, feedback or respond regarding my answer code below:icon_smile:.

If the users enter x as 5, y as 6 the multiple table will be printed as below:

1*6=6
2*6=12
3*6=18
4*6=24
5*6=30

My answer code as below:-/:

/**
 * @(#)qoestion1.java
 *
 *
 * @author 
 * @version 1.00 2009/9/27
 */

public class qoestion1 {

    /**
     * Creates a new instance of <code>qoestion1</code>.
     */
    public qoestion1() {
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
      int x;
      int y=6;


      for (x=1;x<=5;x++)
      {
            System.out.println(x+"*"+y+"="+x*y);


      }
    }
}

Hope to hear your feedback as soon as posible :). I hope I at the right track.

thax......

Edited by mike_2000_17: Fixed formatting

4
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by jonelynne
0

Well the code runs as it's supposed to be.
The code is not very complicated to provide any suggestions on how to do things differently

0

You can use Scanner objects to obtain user input for the values of x and y.
Try:

Scanner inputx = new Scanner(System.in);
Scanner inputy = new Scanner(System.in);
int x = inputx.nextInt();
int y = inputy.nextInt();

This should allow you to include user input in your program.
Is that what you are looking for?

Edited by Grn Xtrm: n/a

0

Thanks:) to Java Addict and Grn Xtrm

Edited by gpremkum: n/a

0

Please mark the thread as solved if your question has been answered. This way the other members of the community don't waste their time reading an already answered question.
Thanks.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.