0
Good, I think I have already achieved what I wanted to thank everyone my only doubt is whether a new number is generated every time the user enters a new guess,here is the new code:
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("Vão agora ser gerados números entre " + min + " e " + max);
double rand = Math.random();
int entreMinEMax =(int) (min +(max - min + 1) * rand);
int palpites = 0;
int acertou = 0;
int errou = 0;
do
{
System . out . println("Indique o seu palpite:");
int palpite = scanner.nextInt ();
if (palpite == entreMinEMax)
{
acertou++;
}else
{
errou++;
}
palpites++;
}while(palpites<10);
System . out . println ("Acertou " + acertou + " " + (acertou/10)*100 + "%");
System . out . println ("Errou " + errou + " " + (errou/10)*100 + "%");
But in the code if the user hits the first, only one question is asked due to the
break
, soon it will never be possible to have a case where it hit 2 as indicated in the question.– Isac