sfrsnyz

Первое тестовое Ноздрюхин Александр

May 20th, 2021
984
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 8.81 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Hello {
  3.     public static void main(String[] args) {
  4.         Scanner scanner=new Scanner(System.in);
  5.         System.out.println("Введите число от 0 до 999: ");
  6.         while(true) {
  7.             int value = scanner.nextInt();
  8.             if(value<0)
  9.                 break;
  10.             int ed = value % 10;
  11.             int des = (value / 10) % 10;
  12.             int sot = (value / 100) % 10;
  13.             StringBuilder str=new StringBuilder();
  14.             if(sot==1)
  15.                 str.append(" сто");
  16.             if(sot==2)
  17.                 str.append(" двести");
  18.             if(sot==3)
  19.                 str.append(" триста");
  20.             if(sot==4)
  21.                 str.append(" четыреста");
  22.             if(sot==5)
  23.                 str.append(" пятьсот");
  24.             if(sot==6)
  25.                 str.append(" шестьсот");
  26.             if(sot==7)
  27.                 str.append(" семьсот");
  28.             if(sot==8)
  29.                 str.append(" восемьсот");
  30.             if(sot==9)
  31.                 str.append(" девятьсот");
  32.             if(des==1){
  33.                 if(ed==0)
  34.                     str.append(" десять");
  35.                 if(ed==1)
  36.                     str.append(" одиннадцать");
  37.                 if(ed==2)
  38.                     str.append(" двенадцать");
  39.                 if(ed==3)
  40.                     str.append(" тринадцать");
  41.                 if(ed==4)
  42.                     str.append(" четырнадцать");
  43.                 if(ed==5)
  44.                     str.append(" пятнадцатьт");
  45.                 if(ed==6)
  46.                     str.append(" шестнадцать");
  47.                 if(ed==7)
  48.                     str.append(" семнадцать");
  49.                 if(ed==8)
  50.                     str.append(" восемнацдать");
  51.                 if(ed==9)
  52.                     str.append(" девятнацдать");
  53.             }
  54.             if (des==2){
  55.                 str.append(" двадцать");
  56.                 if(ed==1)
  57.                     str.append(" один");
  58.                 if(ed==2)
  59.                     str.append(" два");
  60.                 if(ed==3)
  61.                     str.append(" три");
  62.                 if(ed==4)
  63.                     str.append(" четыре");
  64.                 if(ed==5)
  65.                     str.append(" пять");
  66.                 if(ed==6)
  67.                     str.append(" шесть");
  68.                 if(ed==7)
  69.                     str.append(" семь");
  70.                 if(ed==8)
  71.                     str.append(" восемь");
  72.                 if(ed==9)
  73.                     str.append(" девять");
  74.             }
  75.             if (des==3){
  76.                 str.append(" тридцать");
  77.                 if(ed==1)
  78.                     str.append(" один");
  79.                 if(ed==2)
  80.                     str.append(" два");
  81.                 if(ed==3)
  82.                     str.append(" три");
  83.                 if(ed==4)
  84.                     str.append(" четыре");
  85.                 if(ed==5)
  86.                     str.append(" пять");
  87.                 if(ed==6)
  88.                     str.append(" шесть");
  89.                 if(ed==7)
  90.                     str.append(" семь");
  91.                 if(ed==8)
  92.                     str.append(" восемь");
  93.                 if(ed==9)
  94.                     str.append(" девять");
  95.             }
  96.             if (des==4){
  97.                 str.append(" сорок");
  98.                 if(ed==1)
  99.                     str.append(" один");
  100.                 if(ed==2)
  101.                     str.append(" два");
  102.                 if(ed==3)
  103.                     str.append(" три");
  104.                 if(ed==4)
  105.                     str.append(" четыре");
  106.                 if(ed==5)
  107.                     str.append(" пять");
  108.                 if(ed==6)
  109.                     str.append(" шесть");
  110.                 if(ed==7)
  111.                     str.append(" семь");
  112.                 if(ed==8)
  113.                     str.append(" восемь");
  114.                 if(ed==9)
  115.                     str.append(" девять");
  116.             }
  117.             if (des==5){
  118.                 str.append(" пятьдесят");
  119.                 if(ed==1)
  120.                     str.append(" один");
  121.                 if(ed==2)
  122.                     str.append(" два");
  123.                 if(ed==3)
  124.                     str.append(" три");
  125.                 if(ed==4)
  126.                     str.append(" четыре");
  127.                 if(ed==5)
  128.                     str.append(" пять");
  129.                 if(ed==6)
  130.                     str.append(" шесть");
  131.                 if(ed==7)
  132.                     str.append(" семь");
  133.                 if(ed==8)
  134.                     str.append(" восемь");
  135.                 if(ed==9)
  136.                     str.append(" девять");
  137.             }
  138.             if (des==6){
  139.                 str.append(" шестьдесят");
  140.                 if(ed==1)
  141.                     str.append(" один");
  142.                 if(ed==2)
  143.                     str.append(" два");
  144.                 if(ed==3)
  145.                     str.append(" три");
  146.                 if(ed==4)
  147.                     str.append(" четыре");
  148.                 if(ed==5)
  149.                     str.append(" пять");
  150.                 if(ed==6)
  151.                     str.append(" шесть");
  152.                 if(ed==7)
  153.                     str.append(" семь");
  154.                 if(ed==8)
  155.                     str.append(" восемь");
  156.                 if(ed==9)
  157.                     str.append(" девять");
  158.             }
  159.             if (des==7){
  160.                 str.append(" семьдесят");
  161.                 if(ed==1)
  162.                     str.append(" один");
  163.                 if(ed==2)
  164.                     str.append(" два");
  165.                 if(ed==3)
  166.                     str.append(" три");
  167.                 if(ed==4)
  168.                     str.append(" четыре");
  169.                 if(ed==5)
  170.                     str.append(" пять");
  171.                 if(ed==6)
  172.                     str.append(" шесть");
  173.                 if(ed==7)
  174.                     str.append(" семь");
  175.                 if(ed==8)
  176.                     str.append(" восемь");
  177.                 if(ed==9)
  178.                     str.append(" девять");
  179.             }
  180.             if (des==8){
  181.                 str.append(" восемьдесят");
  182.                 if(ed==1)
  183.                     str.append(" один");
  184.                 if(ed==2)
  185.                     str.append(" два");
  186.                 if(ed==3)
  187.                     str.append(" три");
  188.                 if(ed==4)
  189.                     str.append(" четыре");
  190.                 if(ed==5)
  191.                     str.append(" пять");
  192.                 if(ed==6)
  193.                     str.append(" шесть");
  194.                 if(ed==7)
  195.                     str.append(" семь");
  196.                 if(ed==8)
  197.                     str.append(" восемь");
  198.                 if(ed==9)
  199.                     str.append(" девять");
  200.             }
  201.             if (des==9){
  202.                 str.append(" девяносто");
  203.                 if(ed==1)
  204.                     str.append(" один");
  205.                 if(ed==2)
  206.                     str.append(" два");
  207.                 if(ed==3)
  208.                     str.append(" три");
  209.                 if(ed==4)
  210.                     str.append(" четыре");
  211.                 if(ed==5)
  212.                     str.append(" пять");
  213.                 if(ed==6)
  214.                     str.append(" шесть");
  215.                 if(ed==7)
  216.                     str.append(" семь");
  217.                 if(ed==8)
  218.                     str.append(" восемь");
  219.                 if(ed==9)
  220.                     str.append(" девять");
  221.             }
  222.             if(des==0){
  223.                 if(ed==1)
  224.                     str.append(" один");
  225.                 if(ed==2)
  226.                     str.append(" два");
  227.                 if(ed==3)
  228.                     str.append(" три");
  229.                 if(ed==4)
  230.                     str.append(" четыре");
  231.                 if(ed==5)
  232.                     str.append(" пять");
  233.                 if(ed==6)
  234.                     str.append(" шесть");
  235.                 if(ed==7)
  236.                     str.append(" семь");
  237.                 if(ed==8)
  238.                     str.append(" восемь");
  239.                 if(ed==9)
  240.                     str.append(" девять");
  241.             }
  242.             if(sot==0&&des==0&&ed==0){
  243.                 str=new StringBuilder("ноль");
  244.             }
  245.             System.out.println(str.toString());
  246.  
  247.         }
  248.  
  249.     }
  250. }
Advertisement
Add Comment
Please, Sign In to add comment