Essay on Unit 3 Assignment 1

733 Words Apr 10th, 2013 3 Pages
Short Answer: 1. What two things must you normally specify in a variable declaration? a. variable type b. identifier i. int n; // type - int, identifier - n 2. What value is stored in uninitialized variables? c. is a variable that is declared but is not set to a definite known value before it is used.
Algorithm Workbench Review: 3. Write assignment statements that perform the following operations with the variables a, b, and c. d. Adds 2 to a and stores the result in b e. Multiplies b times 4 and stores the result in a f. Divides a by 3.14 and stores the result in b g. Subtracts 8 from b and stores the result in a ii. b = a + 2 iii. a = b * 4
…show more content…
* Declare Integer total=0 * Set total=10+14 9. Write a pseudo code statement that subtracts the variable downpayment from the variable total and assigns the result to the variable due. * Declare Integer downPayment * Declare Integer Total * Declare Integer Due * Set Due = Total - downPayment 10. Write a pseudo code statement that multiplies the variable subtotal by 0.15 and assigns the result to the variable totalfee. l. set totalfee = subtotal * 0.15
Programming Exercise: 1. Sales Tax a. Design a program that will ask the user to enter the amount of a purchase. The program should then compute the state and county sales tax. Assume the state sales tax is 4% and the county sales tax is 2%. The program should display the amount of the purchase, the state sales tax, the county sales tax, the total sales tax, and the total of the sale (which is the sum of the amount of purchase plus the total sales tax.) 1. # Stating the TAX rates 2. STATE_TAX = 0.04 3. COUNTY_TAX = 0.02 4. # Asking the user for price of item 5. price = float(input('How much is the item?: ')) 6. # Calculating both taxes to 1 item 7. total_tax = STATE_TAX + COUNTY_TAX 8. # Calculating the tax with the users price 9. taxed = price * total_tax 10. # Adding the total price with the total

Related Documents