I'm attempting to rewrite the following if statement as a conditional statement.
if (hours > 40) wages *= 1.5; else wages *= 1;
Here is my attempt that works, but I don't think I used the multiplication compound assignment operator correctly or at all.
int hours = 50, wages = 20; System.out.println("Wages = " + (hours > 40 ? wages * 1.5: wages * 1));
Aucun commentaire:
Enregistrer un commentaire