Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Hello {
- public static void main(String[] args) {
- Scanner scanner=new Scanner(System.in);
- System.out.println("Введите число от 0 до 999: ");
- while(true) {
- int value = scanner.nextInt();
- if(value<0)
- break;
- int ed = value % 10;
- int des = (value / 10) % 10;
- int sot = (value / 100) % 10;
- StringBuilder str=new StringBuilder();
- if(sot==1)
- str.append(" сто");
- if(sot==2)
- str.append(" двести");
- if(sot==3)
- str.append(" триста");
- if(sot==4)
- str.append(" четыреста");
- if(sot==5)
- str.append(" пятьсот");
- if(sot==6)
- str.append(" шестьсот");
- if(sot==7)
- str.append(" семьсот");
- if(sot==8)
- str.append(" восемьсот");
- if(sot==9)
- str.append(" девятьсот");
- if(des==1){
- if(ed==0)
- str.append(" десять");
- if(ed==1)
- str.append(" одиннадцать");
- if(ed==2)
- str.append(" двенадцать");
- if(ed==3)
- str.append(" тринадцать");
- if(ed==4)
- str.append(" четырнадцать");
- if(ed==5)
- str.append(" пятнадцатьт");
- if(ed==6)
- str.append(" шестнадцать");
- if(ed==7)
- str.append(" семнадцать");
- if(ed==8)
- str.append(" восемнацдать");
- if(ed==9)
- str.append(" девятнацдать");
- }
- if (des==2){
- str.append(" двадцать");
- if(ed==1)
- str.append(" один");
- if(ed==2)
- str.append(" два");
- if(ed==3)
- str.append(" три");
- if(ed==4)
- str.append(" четыре");
- if(ed==5)
- str.append(" пять");
- if(ed==6)
- str.append(" шесть");
- if(ed==7)
- str.append(" семь");
- if(ed==8)
- str.append(" восемь");
- if(ed==9)
- str.append(" девять");
- }
- if (des==3){
- str.append(" тридцать");
- if(ed==1)
- str.append(" один");
- if(ed==2)
- str.append(" два");
- if(ed==3)
- str.append(" три");
- if(ed==4)
- str.append(" четыре");
- if(ed==5)
- str.append(" пять");
- if(ed==6)
- str.append(" шесть");
- if(ed==7)
- str.append(" семь");
- if(ed==8)
- str.append(" восемь");
- if(ed==9)
- str.append(" девять");
- }
- if (des==4){
- str.append(" сорок");
- if(ed==1)
- str.append(" один");
- if(ed==2)
- str.append(" два");
- if(ed==3)
- str.append(" три");
- if(ed==4)
- str.append(" четыре");
- if(ed==5)
- str.append(" пять");
- if(ed==6)
- str.append(" шесть");
- if(ed==7)
- str.append(" семь");
- if(ed==8)
- str.append(" восемь");
- if(ed==9)
- str.append(" девять");
- }
- if (des==5){
- str.append(" пятьдесят");
- if(ed==1)
- str.append(" один");
- if(ed==2)
- str.append(" два");
- if(ed==3)
- str.append(" три");
- if(ed==4)
- str.append(" четыре");
- if(ed==5)
- str.append(" пять");
- if(ed==6)
- str.append(" шесть");
- if(ed==7)
- str.append(" семь");
- if(ed==8)
- str.append(" восемь");
- if(ed==9)
- str.append(" девять");
- }
- if (des==6){
- str.append(" шестьдесят");
- if(ed==1)
- str.append(" один");
- if(ed==2)
- str.append(" два");
- if(ed==3)
- str.append(" три");
- if(ed==4)
- str.append(" четыре");
- if(ed==5)
- str.append(" пять");
- if(ed==6)
- str.append(" шесть");
- if(ed==7)
- str.append(" семь");
- if(ed==8)
- str.append(" восемь");
- if(ed==9)
- str.append(" девять");
- }
- if (des==7){
- str.append(" семьдесят");
- if(ed==1)
- str.append(" один");
- if(ed==2)
- str.append(" два");
- if(ed==3)
- str.append(" три");
- if(ed==4)
- str.append(" четыре");
- if(ed==5)
- str.append(" пять");
- if(ed==6)
- str.append(" шесть");
- if(ed==7)
- str.append(" семь");
- if(ed==8)
- str.append(" восемь");
- if(ed==9)
- str.append(" девять");
- }
- if (des==8){
- str.append(" восемьдесят");
- if(ed==1)
- str.append(" один");
- if(ed==2)
- str.append(" два");
- if(ed==3)
- str.append(" три");
- if(ed==4)
- str.append(" четыре");
- if(ed==5)
- str.append(" пять");
- if(ed==6)
- str.append(" шесть");
- if(ed==7)
- str.append(" семь");
- if(ed==8)
- str.append(" восемь");
- if(ed==9)
- str.append(" девять");
- }
- if (des==9){
- str.append(" девяносто");
- if(ed==1)
- str.append(" один");
- if(ed==2)
- str.append(" два");
- if(ed==3)
- str.append(" три");
- if(ed==4)
- str.append(" четыре");
- if(ed==5)
- str.append(" пять");
- if(ed==6)
- str.append(" шесть");
- if(ed==7)
- str.append(" семь");
- if(ed==8)
- str.append(" восемь");
- if(ed==9)
- str.append(" девять");
- }
- if(des==0){
- if(ed==1)
- str.append(" один");
- if(ed==2)
- str.append(" два");
- if(ed==3)
- str.append(" три");
- if(ed==4)
- str.append(" четыре");
- if(ed==5)
- str.append(" пять");
- if(ed==6)
- str.append(" шесть");
- if(ed==7)
- str.append(" семь");
- if(ed==8)
- str.append(" восемь");
- if(ed==9)
- str.append(" девять");
- }
- if(sot==0&&des==0&&ed==0){
- str=new StringBuilder("ноль");
- }
- System.out.println(str.toString());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment