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;
}
}
}
Я пытаюсь сделать программу подсчета пропусков. Когда я компилирую этот код, строка while(counter2 = counter3){
отображается как ошибка Несовместимые типы. Компилятор говорит, что нашел «int», но требует «логического». Имейте в виду, что я новичок, поэтому я еще не изучил логики в своем классе Java.Java: Несовместимые типы (int/boolean)
Как бы сделать цикл while в правильном цикле? Прямо сейчас, после применения исправления Mik378, цикл не активируется. –
Каковы текущие значения для 'counter2' и' counter3', если вы положили точку останова на строку 'while'? – Mik378