Answer the question
In order to leave comments, you need to log in
What is the correct way to calculate the remainder of a division?
Hello everyone, there is a code example in which everything is very clear.
You need to write a program in which the user enters the number 13767 and receives it in response.
import pack;
public class Test {
public static void main(String[] args) {
try (Scanner sc = new Scanner(System.in)) {
int number, a, b, c, d, e;
System.out.println("number");
number = sc.nextInt();
a = number / 10000;
b = number % 10000 / 1000;
c = number % 1000 / 100;
d = number % 100 / 10;
e = number % 10;
System.out.println(+a);
System.out.println(+b);
System.out.println(+c);
System.out.println(+d);
System.out.println(+e);
}
}
}
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
try (Scanner sc = new Scanner(System.in)) {
int number, a, b, c, d, e;
System.out.println("number");
number = sc.nextInt();
a = number / 11284;
b = number % 10000 / 1000;
c = number % 1000 / 100;
d = number % 100 / 10;
e = number % 10;
System.out.println(+a);
System.out.println(+b);
System.out.println(+c);
System.out.println(+d);
System.out.println(+e);
}
}
}
Answer the question
In order to leave comments, you need to log in
To begin with, decide what you mean by the word "breaks" - does it fall (Exeption), gives an incorrect result (different from the expected one), asks you to first take it to the cinema? (By the way, as far as I can see it works)
Just simply in a few columns for each line write: What (in your opinion) should your variables be equal before execution, what (in your opinion) should be the result, what your variables actually equal before executing what actually happened as a result.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question