changed the file structure
This commit is contained in:
parent
cd81159162
commit
b1c3582880
391 changed files with 675 additions and 0 deletions
31
Code/Steiner/bookAufgabe3/src/App.java
Normal file
31
Code/Steiner/bookAufgabe3/src/App.java
Normal file
|
@ -0,0 +1,31 @@
|
|||
|
||||
// împort java extansions
|
||||
import java.util.Scanner;
|
||||
|
||||
public class App {
|
||||
public static void main(String[] args) {
|
||||
Scanner scan = new Scanner(System.in);
|
||||
|
||||
System.out.println("Give me a number please:");
|
||||
int number = scan.nextInt();
|
||||
int math = 0;
|
||||
int numberOfDigits = 0;
|
||||
int sum = 0;
|
||||
|
||||
// Number of digits
|
||||
for (int tempNumber = number; tempNumber > 0; tempNumber = tempNumber / 10) {
|
||||
numberOfDigits++;
|
||||
}
|
||||
|
||||
// math the digits-diffrence
|
||||
for (int tempNumber = number; tempNumber > 0; tempNumber = tempNumber / 10) {
|
||||
math = tempNumber % 10;
|
||||
sum += math;
|
||||
}
|
||||
|
||||
System.out.println("Anzahl der Ziffern: " + numberOfDigits);
|
||||
System.out.println("Ziffernsumme: " + sum);
|
||||
|
||||
scan.close();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue