import java.util.* ;
class Main {
public static long converte
( String entrada
) { switch ( entrada) {
case "um" :
return 1 ;
case "dois" :
return 2 ;
case "três" :
return 3 ;
case "quatro" :
return 4 ;
case "cinco" :
return 5 ;
case "seis" :
return 6 ;
case "sete" :
return 7 ;
case "oito" :
return 8 ;
case "nove" :
return 9 ;
case "dez" :
return 10 ;
default :
return - 1 ;
}
}
public static void main
( String [ ] args
) { Scanner key
= new Scanner
( System .
in ) ; System .
out .
println ( "Inicialização...\n Instruções:\n 1-Digite o nome de um número entre um~dez.\n 2-O programa encerra ao digitar 'fim'." ) ; while ( true ) {
String entrada
= key.
nextLine ( ) ; if ( entrada.equals ( "fim" ) ) break ;
long convertido = converte( entrada) ;
if ( convertido == - 1 ) {
System .
out .
println ( "Palavra inválida" ) ; continue ;
}
System .
out .
println ( convertido
) ; }
key.close ( ) ;
}
}
//https://pt.stackoverflow.com/q/256361/101
aW1wb3J0IGphdmEudXRpbC4qOwoKY2xhc3MgTWFpbiB7CiAgICBwdWJsaWMgc3RhdGljIGxvbmcgY29udmVydGUoU3RyaW5nIGVudHJhZGEpIHsKCSAgICBzd2l0Y2ggKGVudHJhZGEpIHsKCSAgICBjYXNlICJ1bSI6CgkgICAgICAgIHJldHVybiAxOwoJICAgIGNhc2UgImRvaXMiOgoJICAgICAgICByZXR1cm4gMjsKCSAgICBjYXNlICJ0csOqcyI6CgkgICAgICAgIHJldHVybiAzOwoJICAgIGNhc2UgInF1YXRybyI6CgkgICAgICAgIHJldHVybiA0OwoJICAgIGNhc2UgImNpbmNvIjoKCSAgICAgICAgcmV0dXJuIDU7CgkgICAgY2FzZSAic2VpcyI6CgkgICAgICAgIHJldHVybiA2OwoJICAgIGNhc2UgInNldGUiOgoJICAgICAgICByZXR1cm4gNzsKCSAgICBjYXNlICJvaXRvIjoKCSAgICAgICAgcmV0dXJuIDg7CgkgICAgY2FzZSAibm92ZSI6CgkgICAgICAgIHJldHVybiA5OwoJICAgIGNhc2UgImRleiI6CgkgICAgICAgIHJldHVybiAxMDsKCSAgICBkZWZhdWx0OgoJICAgICAgICByZXR1cm4gLTE7CgkgICAgfQoJfQoJcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nW10gYXJncykgewoJICAgIFNjYW5uZXIga2V5ID0gbmV3IFNjYW5uZXIoU3lzdGVtLmluKTsKCSAgICBTeXN0ZW0ub3V0LnByaW50bG4oIkluaWNpYWxpemHDp8Ojby4uLlxuSW5zdHJ1w6fDtWVzOlxuMS1EaWdpdGUgbyBub21lIGRlIHVtIG7Dum1lcm8gZW50cmUgdW1+ZGV6LlxuMi1PIHByb2dyYW1hIGVuY2VycmEgYW8gZGlnaXRhciAnZmltJy4iKTsKCSAgICB3aGlsZSAodHJ1ZSkgewoJICAgICAgICBTdHJpbmcgZW50cmFkYSA9IGtleS5uZXh0TGluZSgpOwoJICAgICAgICBpZiAoZW50cmFkYS5lcXVhbHMoImZpbSIpKSBicmVhazsKCSAgICAgICAgbG9uZyBjb252ZXJ0aWRvID0gY29udmVydGUoZW50cmFkYSk7CgkgICAgICAgIGlmIChjb252ZXJ0aWRvID09IC0xKSB7CgkgICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIlBhbGF2cmEgaW52w6FsaWRhIik7CgkgICAgICAgICAgICBjb250aW51ZTsKCSAgICAgICAgfQogICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oY29udmVydGlkbyk7CgkgICAgfQoJICAgIFN5c3RlbS5vdXQucHJpbnRsbigiRmltISIpOwoJICAgIGtleS5jbG9zZSgpOwoJfQp9CgovL2h0dHBzOi8vcHQuc3RhY2tvdmVyZmxvdy5jb20vcS8yNTYzNjEvMTAx