Wednesday, January 29, 2014

Section 3.1: Numbers - Arithmetic Operators




40905:  Assume an int variable x has already been declared.  Write an expression whose value is 1 more than x.

x + 1

40044:  Write an expression that computes the sum of two double variables total1 and total2 which have been already declared and assigned values.

total1 + total2

40326:  Write an expression that computes the sum of the two variables verbalScore and mathScore (already declared and assigned values).

verbalScore + mathScore

40327:  Given the variables taxablePurchases and taxFreePurchases (already declared and assigned values), write an expression corresponding to the total amount purchased.

taxablePurchases + taxFreePurchases

40328:  Write an expression that computes the difference of the variables endingTime and startingTime.

endingTime - startingTime

40329:  Given the variables fullAdmissionPrice and discountAmount (already declared and assigned values), write an expression corresponding to the price of a discount admission.  (The variable discountAmount holds the actual amount discounted, not a percentage.)

fullAdmissionPrice - discountAmount

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

pricePerCase * 12

41014:  A wall has been built with two pieces of sheetrock, a smaller one and a larger one.  The length of the smaller one is stored in the variable small.  Siumilarly, the length of the larger one is stored int he variable large.  Write a single expression whose value is the length of this wall.

small + large

40045:  Write an expression that computes the difference of two double variables salesSummer and salesSpring, which have been already declared and assigned values.

salesSummer - salesSpring

40046:  You are given two double variables, already declared and assigned values, named totalWeight, containing the weight of a shipment, and weightOfBox, containing the weight of the box in which a product is shipped.  Write an expression that calculates the net weight of the product.

totalWeight - weightOfBox

40047:  You are given two variables, already declared and assigned values, one of type double, named totalWeight, containing the weight of a shipment, and the other of type int, named quantity, containing the number of items in the shipment.  Write an expression that calculates the weight of one item.

totalWeight . quantity

40048:  You are given two variables, already declared and assigned values, one of type double, named price, containing the price of an order, and the other of type int, named totalNumber, containing the number of orders.  Write an expression that calculates the total price for all orders.

price * totalNumber

1 comment:

  1. 40047: You are given two variables, already declared and assigned values, one of type double, named totalWeight, containing the weight of a shipment, and the other of type int, named quantity, containing the number of items in the shipment. Write an expression that calculates the weight of one item.

    solution should be like this :
    totalWeight / quantity not like this --- totalWeight . quantity

    ReplyDelete