Variables Worksheet #2 Name -
  Day of Week -

1. Identify each of the following as either a declaration statement, an assignment statement, or a comment statement.

______________________________ a/ apples = 50;
______________________________ b/ int dollars = 0;
______________________________ c/ // John Doe
______________________________ d/ cost = 0.50 * apples;
______________________________ e/ double cost = 0.0;
______________________________ f/ // variable declarations
______________________________ g/ const double SALES_TAX = 0.06;

2. Which data type - double or int - would be the most appropriate for a variable that would be used in a program to store.....

____________ a/ the quantity of apples purchased
____________ b/ the cost of an Ipod
____________ c/ the number of people that live in New York City
____________ d/ the number of people that live on Earth
____________ e/ your future salary in $


3. Write a single cout statement that would display your last name on one line of output along with your phone number on a second line of output. Do not use two separate cout statements.

 

4. Write a single assignment statement that would computes the amount of sales tax that would need to be paid on a purchase and stores that computed amount of tax in the variable totalTax. Assume that the amount of the purchase is stored in the variable basePrice and that the tax rate is 6% (i.e. 0.06 as a percentage).