Created
July 3, 2017 13:42
-
-
Save P0huber/2a1a7e1fde71ed5d00af019e78ef940a to your computer and use it in GitHub Desktop.
Таблица умножения с помощью while. The multiplication table through while [Java]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.javarush.task.task04.task0434; | |
/* | |
Таблица умножения | |
*/ | |
public class multiplicationTable { | |
private static String multiplication(int s){ | |
int a = 1, g = 1; | |
String n = "";//this variable specifically for return | |
while (a < 11) {//the creation of row containing 10 values (s * g + " ") of the cycle | |
System.out.print(s * g + " "); | |
a++;//the counter of cycle | |
g++;//the multiplier of every value of row | |
}return n;//it`s returns String n = null, because that is 11th element of every row. | |
} | |
public static void main(String[] args) throws Exception { | |
int a = 1, s = 1;//argument "s" is main value of elements table. It is sets first element of every row and etc | |
while(a < 11) {//the cycle of creation tabulation of 10 rows | |
System.out.println(multiplication(s++));//10 calls of the method with the argument "s" | |
a++; | |
} | |
} | |
} | |
/*Таблица умножения | |
Вывести на экран таблицу умножения 10х10 используя цикл while. | |
Числа разделить пробелом. | |
Пример вывода на экран: | |
1 2 3 4 5 6 7 8 9 10 | |
2 4 6 8 10 12 14 16 18 20 | |
3 6 9 12 15 18 21 24 27 30 | |
4 8 12 16 20 24 28 32 36 40 | |
5 10 15 20 25 30 35 40 45 50 | |
6 12 18 24 30 36 42 48 54 60 | |
7 14 21 28 35 42 49 56 63 70 | |
8 16 24 32 40 48 56 64 72 80 | |
9 18 27 36 45 54 63 72 81 90 | |
10 20 30 40 50 60 70 80 90 100 | |
Требования: | |
1. Программа не должна считывать текст c клавиатуры. | |
2. Программа должна выводить текст на экран. | |
3. Программа должна выводить таблицу умножения 10х10. | |
4. В программе должен использоваться цикл while.*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment