Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.54 KB | None | 0 0
  1. public class Main {
  2.  
  3.  
  4.  
  5.     public static void main(String[] args) {
  6.         int n = -18;
  7.         int k = 0;
  8.         if (n < 0) {
  9.             System.out.print("minus-");
  10.             n = -n;
  11.         }
  12.         int n1 = n;
  13.         while (n1>0){
  14.             k++;
  15.             n1 = n1/10;
  16.         }
  17.         int [] a = new int [k];
  18.         for (int i = 0; i < k; i++) {
  19.             a[i] = n % 10;
  20.             n = n/10;
  21.         }
  22.  
  23.         for (int i = k-1; i > 0; i--) {
  24.             if (a[i] == 0) System.out.print("null");
  25.             if (a[i] == 1) System.out.print("eins");
  26.             if (a[i] == 2) System.out.print("zwei");
  27.             if (a[i] == 3) System.out.print("drei");
  28.             if (a[i] == 4) System.out.print("vier");
  29.             if (a[i] == 5) System.out.print("fuenf");
  30.             if (a[i] == 6) System.out.print("sechs");
  31.             if (a[i] == 7) System.out.print("sieben");
  32.             if (a[i] == 8) System.out.print("acht");
  33.             if (a[i] == 9) System.out.print("neun");
  34.             System.out.print("-");
  35.         }
  36.         if (a[0] == 0) System.out.print("null");
  37.         if (a[0] == 1) System.out.print("eins");
  38.         if (a[0] == 2) System.out.print("zwei");
  39.         if (a[0] == 3) System.out.print("drei");
  40.         if (a[0] == 4) System.out.print("vier");
  41.         if (a[0] == 5) System.out.print("fuenf");
  42.         if (a[0] == 6) System.out.print("sechs");
  43.         if (a[0] == 7) System.out.print("sieben");
  44.         if (a[0] == 8) System.out.print("acht");
  45.         if (a[0] == 9) System.out.print("neun");
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement