Monday, June 18, 2012

Homework 2: Assignment

1. Given an integer variable  drivingAge that has already been declared, write a statement that assigns the value 17 to  drivingAge .

drivingAge = 17 ;

2.  Given two integer variables  oldRecord and  newRecord , write a statement that gives  newRecord the same value that  oldRecord has.

newRecord = oldRecord ;

3. Given two integer variables  matricAge and  gradAge , write a statement that gives  gradAge a value that is 4 more than the value of  matricAge .  

gradAge = matricAge + 4 ;

4. Given an integer variable  bridgePlayers , write an statement that increases the value of that variable by 4. 

bridgePlayers= 4 + bridgePlayers;

5. Given an integer variable  profits , write a statement that increases the value of that variable by a factor of 10. 

profits = profits * 10 ;

6. Given an integer variable  strawsOnCamel , write a statement that uses the auto-increment operator to increase the value of that variable by 1. 

strawsOnCamel ++ ;

7. Given an integer variable  timer , write a statement that uses the auto-decrement operator to decrease the value of that variable by 1. 

timer --;

No comments:

Post a Comment