public class LabProgram {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int userNum=in.nextInt();
int divNum=in.nextInt();
int i=0;
while(i<3){
userNum=userNum/divNum;
if(userNum==0);
System.out.print(userNum "" "\n");
i ;
}
}
}
This results in an output formatted like this,
1000
500
250
Output is nearly correct; but whitespace differs. See highlights below.
Special character legend
Input
2000 2
Your output
1000
500
250
Expected output
1000 500 250
I want it to be like this 1000 500 250 (newline here)
How do I do this?
CodePudding user response:
Maybe let's try this one:
System.out.print(userNum " ");
And at the end use this:
System.out.println();
or
System.out.print("\n");
This will add you a newline :)
CodePudding user response:
Use
System.out.println(userNum);