How to sum up the resultes in a while loop while centain input will end the while loop?
问题 I have a situation in java; I would like to ask the user to put in some numbers & have a total of those numbers. However if the user enter a negative number it will end the loop; currently I have a while loop as below; double sum = 0; double Input = 0; System.out.println("Please enter the numbers (negative to end)") System.out.println("Enter a number"); Scanner kdb = new Scanner(System.in); Input = kdb.nextDouble(); while (Input > 0) { System.out.println("Enter an income"); Input = kdb