Question: Integer userNum is read from input. Write a while loop that divides userNum by 9, updating userNum with the quotient, and outputs the updated userNum,
Integer userNum is read from input. Write a while loop that divides userNum by 9, updating userNum with the quotient, and outputs the updated userNum, followed by a newline. The loop iterates until userNum is less than or equal to 0.
Ex: If the input is 729, then the output is:
81 9 1 0
import java.util.Scanner;
public class QuotientCalculator {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
int userNum;
userNum = scnr.nextInt();
}
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
