Monday, June 18, 2012

Homework 4: Operations-2

1. Given the variable  pricePerCase , write an expression corresponding to the price of a dozen cases.

pricePerCase * 12

2. Given the variables  costOfBusRental and  maxBusRiders , write an expression corresponding to the cost per rider (assuming the bus is full).

costOfBusRental / maxBusRiders

3. Assume that  children is an integer variable containing the number of children in a community and that  families is an integer variable containing the number of families in the same community. Write an expression whose value is the average number of children per family. 

( double ) children / families

4. Write an expression that computes the remainder of the variable  principal when divided by the variable  divisor . (Assume both are type  int .) 

principal % divisor

5.  Assume that  price is an integer variable whose value is the price (in US currency) in cents of an item. Assuming the item is paid for with a minimum amount of change and just single dollars, write an expression for the amount of change (in cents) that would have to be paid. 

price % 100


No comments:

Post a Comment