I am a beginner to java programming and have an issue with figuring out how to cap an amount in my code.
I have an issue with my code which is made up of if-else if statements, this is more a question of how to cap the maximum amount of prize money. I want my maximum amount of prize money to be 300 dollars. I do not want any of the contestants to receive more than this. The equation that determines this is
prize= (60-mins4)*10/2;
this determines based on the contestants time the amount of cash they receive. The issue is if they exceed 300 dollars, I want to be able to have the system automatically return it to 300. I am asking what method that I can use to do this or if there is a way to cap the amount?
Aucun commentaire:
Enregistrer un commentaire