Monday, 19 August 2013

Java: Incompatible Types (int/boolean)

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 to Adam's skip-counting program!");
System.out.println("Please input the number you would like to skip
count by.");
counter1 = Integer.parseInt(br.readLine());
System.out.println("Please input the number you would like to start
at.");
counter2 = Integer.parseInt(br.readLine());
System.out.println("Please input the number you would like to
stop at.");
counter3 = Integer.parseInt(br.readLine());
System.out.println("This is skip counting by" +
counter1 + ", starting at" + counter2 + "and ending
at" + counter3 +":");
while(counter2 = counter3){
counter2 = counter2 + counter1;
counter3 = counter2 + counter1;
}
}}
I am trying to make skip-counting program. When I compile this code, the
line "while(counter2 = counter3){" shows up as a Incompatible Types error.
The compiler says it found an "int" but it requires a "boolean". Please
keep in mind that I am a newbie, so I have not learned booleans in my Java
class yet.

No comments:

Post a Comment