Scanner sc = new Scanner(System.in);
public class NumberDecomposer {
public static void main(String[] args) {
decompose(1212345);
decompose(24123457);
}
private static void decompose(int modelCode) {
System.out.println("Original modelCode="+modelCode);
int factor = 1;
int modelNumber = 0;
while (modelCode >= 100) {
int lastDigit = modelCode % 10;
modelNumber += lastDigit * factor;
factor *= 10;
modelCode /= 10;
}
int productCode = modelCode % 10;
int category = modelCode / 10;
System.out.printf("Category=%d; Product=%d; Model number=%d
", category, productCode, modelNumber);
}
}
Code Example |
---|
Java :: multiplication table in java |
Java :: java alert box |
Java :: getconstructor java |
Java :: java stack |
Java :: android studio textbox change text |
Java :: .now() java |
Java :: joptionpane |
Java :: java filedialog |
Java :: java print text with variables |
Java :: shell sort java |
Java :: android vibrate |
Java :: scanner check if int |
Java :: rps java |
Java :: println java |
Java :: java string remove more than one space |
Java :: read json file java |
Java :: java calendar hour vs hour of day |
Java :: full screen dialog android |
Java :: Spring boot fix cors problem |
Java :: intent filter |
Java :: android check if app is running |
Java :: java arraylist to array |
Java :: inputstream to string java |
Java :: initialize arraylist |
Java :: java setbounds |
Java :: list of lists java |
Java :: java terminal colors |
Java :: int to byte |
Java :: android list[index] |
Java :: keytool error: java.io.FileNotFoundException: c:UsersUSER_NAMEupload-keystore.jks (The system cannot find the path specified) |