I am new to java coding and while loops are a little confusing to me.
For this program I am asked to generate a random number between 1 and 100, I think I've got that part down.
First the code would print out the random value, and then, if the number is even, it prints out that number of "*" characters, and if its odd, it prints out that number of "&" characters.
I know you could use like modulus to determine odd/even but I don't know how to print out a certain number of characters using the while loop, thanks!
Example output would be:
Random number generated: 8 The output pattern: ********
Random number generated:3 The output pattern: &&&
Aucun commentaire:
Enregistrer un commentaire