Monday, June 18, 2012

Homework 4: Simple_if

1. Write a conditional that assigns  true to the variable  fever if the variable  temperature is greater than  98.6 .


if ( temperature > 98.6 ) fever = true ;

2. Write a conditional that assigns  10,000 to the variable  bonus if the value of the variable  goodsSold is greater than  500,000 . 

if ( goodsSold > 500000 ) bonus = 10000 ;

3.  Write a conditional that decreases the variable  shelfLife by  4 if the variable  outsideTemperature is greater than  90 . 

if ( outsideTemperature > 90 ) shelfLife = shelfLife - 4 ;

4.  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. 

if ( workedOvertime == true ) pay = pay * 1.5 ;

No comments:

Post a Comment