Hi, i think, my solution to "Multiplication table" task works well.
The table is displayed, it contains 10 lines, and the numbers are right. I used the "for" cycle.
But the task-verifier said the follows:
The program should output text. - GREEN
The displayed text should contain 10 lines. - RED
Each displayed string must contain 10 numbers separated by spaces. - RED
The displayed numbers must form a multiplication table. - RED
I don't understand why!
- - - - - - - - - - - -
But, i made an other version, see below.
I converted the numbers in one line into one string, and these lines doesn't contain space at the end of the lines, but the task-verifier says the same!:-/
public class Solution {
static int a=1;
static int b=1;
static String resultText = "";
static int result;
public static void product() {
for(; b<11; b++) {
resultinOneLine();
}
}
public static void resultinOneLine(){
for(; a<11; a++){
result = (a*b);
resultText= resultText + Integer.toString(result);
if (a<10) {
resultText += " ";
}
else {
}
}
System.out.println(resultText);
a=1;
resultText = "";
}
public static void main (String[] args){
product();
}
}
package com.codegym.task.task03.task0314;
/*
Multiplication table
*/
public class Solution {
static int a=1;
static int b=1;
public static void product() {
for(; b<11; b++) {
resultinOneLine();
System.out.println("");
}
}
public static void resultinOneLine(){
for(; a<11; a++){
System.out.print(a*b + " ");
}
a=1;
}
public static void main (String[] args){
product();
}
}