Z
Z
ZymBo2020-10-22 15:46:03
Java
ZymBo, 2020-10-22 15:46:03

How to create a multiplication table from 1 to 10 using a for loop?

Yes, sir. I started learning Java two weeks ago. And so what seems intuitive to you may seem very confusing to me. Therefore, I ask you to help me. I need to write a code that, after running it, will display the multiplication table in the run window. For example:
If I write the number 1 Then the multiplication table for one will appear.
If I write the number 2, then the multiplication table by two will appear.
Oh, and one more thing. You will need to use Scanner. Thanks in advance to those who help me.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Orkhan, 2020-10-22
@ZymBo

It is important to outline some algorithm or steps in your head to implement your task.
Well, firstly, the user enters a number and a table is drawn in response. This means that you need to learn Scanner first. Pay attention to scanner.nextInt()Examine the construction switch case
For example, we receive a numeric input from the user. We run through the cases and if there is a match, then we display the corresponding multiplication table.
To draw the multiplication table, you can use libraries for working with ASCII. For example, ASCIITable
https://github.com/vdmeer/asciitable
But since you are a novice developer, you can simply print the matrix. To do this, examine arrays and pay attention to the array of arrays. int [] []
And write the code yourself. I gave you an idea

G
GavriKos, 2020-10-22
@GavriKos

If you study, then the code written by someone will only harm you.
Write it yourself, write an algorithm, etc. And then if they tell you something.
But writing code for someone who LEARNS is a disservice

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question