Java: Incompatible Types (int/boolean) -
import java.io.*; public class adamhmwk4 { public static void main(string [] args) throws ioexception { bufferedreader br = new bufferedreader(new inputstreamreader(system.in)); int counter1; int counter2; int counter3; string answer = ""; system.out.println("welcome adam's skip-counting program!"); system.out.println("please input number skip count by."); counter1 = integer.parseint(br.readline()); system.out.println("please input number start at."); counter2 = integer.parseint(br.readline()); system.out.println("please input number stop at."); counter3 = integer.parseint(br.readline()); system.out.println("this skip counting by" + counter1 + ", starting at" + counter2 + "and ending at" + counter3 +":"); while (counter2 = counter3) { counter2 = counter2 + counter1; counter3 = counter2 + counter1; } } }
i trying make skip-counting program. when compile code, line while(counter2 = counter3){
shows incompatible types error. compiler says found "int" requires "boolean". please keep in mind newbie, have not learned booleans in java class yet.
you can't compare values =
, assignment operator. use ==
compare values. change
while(counter2 = counter3){
to
while(counter2 == counter3){
here's introductory page java operators.
Comments
Post a Comment