/* package whatever; // don't place package name! */
import java.util.* ;
import java.lang.* ;
import java.io.* ;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
Scanner scanner
= new Scanner
( System .
in ) ; System .
out .
println ( "Indique um valor minimo" ) ; int min = scanner.nextInt ( ) ;
System .
out .
println ( "Indique um valor máximo" ) ; int max = scanner.nextInt ( ) ;
System .
out .
println ( "Vai agora ser gerado um número entre " + min
+ " e " + max
) ; double rand
= Math .
random ( ) ; int entreMinEMax = ( int ) ( min + ( max - min + 1 ) * rand) ;
for ( int resposta= 0 ; resposta < 10 ; resposta++ )
{
System .
out .
println ( "Indique o seu palpite:" ) ; int palpite = scanner.nextInt ( ) ;
if ( palpite == entreMinEMax)
{
double sucesso = ( 10.0 - resposta) / 10 ;
System .
out .
println ( "Parabéns!!Acertou!!" ) ; System .
out .
println ( "Percentagem de sucesso: " + ( sucesso
* 100 ) + "%" ) ; break ;
}
}
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgSWRlb25lCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoJICAgIFNjYW5uZXIgc2Nhbm5lciA9IG5ldyBTY2FubmVyKFN5c3RlbS5pbik7CgkgICAgU3lzdGVtIC4gb3V0IC4gcHJpbnRsbigiSW5kaXF1ZSB1bSB2YWxvciBtaW5pbW8iKTsKCSAgICBpbnQgbWluID0gc2Nhbm5lci5uZXh0SW50KCk7CgkgICAgU3lzdGVtIC4gb3V0IC4gcH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