0

Int cannot be Converted to boolean

Im newbie in code today i have code but i have a error somebody help me pls

9th Apr 2020, 3:05 AM
ChaoSKiz
ChaoSKiz - avatar
2 odpowiedzi
+ 3
The error is occurring with the 2nd segment of the for loops. you should use a < or <= instead of = only. for(int s = 1; s < Songaunhien - line; s++) But that will only fix the error message. there are also issues with your random number generator line. you need to fix the () around int and Math. (int)(Math.random(). also your final value for Songaunheim cannot be negative or your loops will not work.
9th Apr 2020, 5:56 AM
Elizabeth Kelly
Elizabeth Kelly - avatar
0
My code: public class Program { public static void main(String[] args) { int max = 10; int min = 5; int range = (max - min)+1; int Songaunhien = 0; Songaunhien = ((int)Math.random() * range) - min; String result = " "; String space = " "; String character = " "; int line = 1; while(line <= Songaunhien){ space = " "; character = " "; for(int s = 1; s = Songaunhien - line; s++) space += " "; for(int c = 1; c = 2*line - 1; c++) character += "* "; result = space + character + "\n "; line++; } System.out.println(result); } }
9th Apr 2020, 3:05 AM
ChaoSKiz
ChaoSKiz - avatar