Variables Worksheet #1 | Name - |
Day of Week - |
1. List a valid and logical variable name for a variable that would store the total price of a customer's purchase. Make sure that you also follow the conventions discussed in class such as beginning a variable name with a lowercase letter and beginning successive words with a capital letter.
2. Write a declaration statement that declares an int variable named numApples and intializes it to the value zero.
3. Write an assignment statement that assigns the value 10 to the variable numApples.
4. Write an assignment statement that adds 5 to the value stored in numApples and assigns the resulting sum to the variable totalApples.
5. Write an assignment statement that subtracts 3 from the value stored in numApples & assigns the result back into the variable numApples.
6. Write an assignment statement that subtracts 3 from the value stored in numApples & assigns the result back into the variable numApples using the -= compound operator.
7. Write an assignment statement that adds one to the variable numApples using the incrementing operator.