Variables Worksheet #5 | Name - |
Day of Week - |
1. What are the values of the following expressions after the following statements have executed. If a value is a floating-point value, show a decimal point (e.g. instead of 4 write the answer 4.)
int apples = 10;
int bananas;
double cost = 8.0;
double priceApples = 0.5;
a/ | (apples + 6) / 2 | |
b/ | (apples + 6) / 2.0 | |
c/ | cost - apples * priceApples | |
d/ | cost - apples * int (priceApples) | |
e/ | apples % 3 * 2 | |
f/ | 10.0 + apples * priceApples | |
g/ | (apples + bananas) * priceApples |
2. Write a complete program that computes & displays the total amount of profit that that a charity organization earns in the following scenario. The charity holds a car wash where the price of each 2-door vehicle washed is $10 and vehicles with more than 2-doors is $15. It costs the charity $200 to rent the car washing location and supplies (towels, soap, etc.) cost $3 per car washed. (Assume that no supplies are wasted and that they are all used up.) The user inputs the number of 2-door vehicles and the number of vehicles with more than 2-doors that are washed.
3. Write a complete program that prompts the user to input a positive, floating-point value (i.e. decimal number). After accepting the user-inputted value, the program must display the value rounded to the nearest whole number. Write your program on the back of the paper.