System.out.println("Do you want to add 1? if yes type in '0.01' ");问题在于它只运行一次。我试图将它添加到一个 while 循环中 (while(i > 100)) 但它只是简单地打印到 100 而没有再次询问用户我的代码:import java.util.Scanner;public class Main { public static void main(String[] args) { int i = 0; double yes = 0.01; System.out.println("i = " + i); System.out.println("Do you want to add 1? if yes type in '0.01' "); Scanner keyboardInput = new Scanner(System.in); double add = keyboardInput.nextDouble(); if (yes == add) { i++; System.out.println("i now is: " + i); } }}
添加回答
举报
0/150
提交
取消