99.4k views
4 votes
Write a conditional that multiplies the values of the variable pay by one-and-a-half if the value of the boolean variable workedOvertime is true.

User Matewka
by
5.6k points

1 Answer

3 votes

Answer:

workedOvertime==true ? pay=pay*1.5 : pay ;

Step-by-step explanation:

Above written statement is written by using the conditional operator. Conditional operator uses ? : .The expression written on the left is evaluated if it comes out to be true then the written to the left of : and to the right of ? will be executed if it is false then the expression on the right of : will be executed. In above expression If workedOver time is true then pay will be multiplied ny 1.5 else it does not do anything.

User MuttonUp
by
4.9k points