public class Solution {
public static void main(String[] args) throws Exception {
//напишите тут ваш код
getRectangle(getNumber(), getNumber());
}
public static void getRectangle (int m, int n) {
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
System.out.print(8);
}
System.out.println();
}
Решил задачу примерно так:
}
public static int getNumber () {
Scanner sc = new Scanner(System.in);
while (!sc.hasNextInt()) {
sc.next();
}
return sc.nextInt();
}
}
Валидатор проходит все проверки, но ругается на то, что я использую цикл while вместо for.
Помогите понять, что не нравится валидатору.package com.javarush.task.task04.task0436;
/*
Рисуем прямоугольник
*/
import java.io.*;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) throws Exception {
//напишите тут ваш код
getRectangle(getNumber(), getNumber());
}
public static void getRectangle (int m, int n) {
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
System.out.print(8);
}
System.out.println();
}
}
public static int getNumber () {
Scanner sc = new Scanner(System.in);
while (!sc.hasNextInt()) {
sc.next();
}
return sc.nextInt();
}
}