SEPT 18 LAB PRACTICE - Test 1 CSCI 151 Preparation

Test 1 Info

Question 1

For the program below, write calculations performed on each line and write the final output. Explain the order of arithmetic operations in 5th statement.

Question 2

The person is purchasing apples and apple pies in the store. Write the program that reads the number of pounds and price per pound for apples, the number of pies and price of one pie, and the tax (integer). The program finds and prints the total purchase price. For example, if the person purchased 3 pounds of apples, 1.99 per pound, and 2 apple pies, 7.99 each, and the tax is 6%, the total purchase price is: 23.27 dollars.

Question 3

Widener Programming Team traveled from Chester, PA to Worcester, MA, to compete in the regional programming contest. The team traveled on THREE different types of roads, RURAL, URBAN, and HIGHWAY, with different speed limits. Write a program that asks user to enter the number of hours team traveled on each type of roads and the travel speed for each type. The program calculates the total distance the team traveled and the average speed. Use the following formulas: DISTANCE = SPEED*TIME, SPEED = DISTANCE/TIME

Use the following example to test your program: team traveled 2.5 hours with speed 65 MPH (miles per hour), 1.5 hours with speed 55 MPH and 1.5 hours with speed 35 MPH. The total distance is:
2.5*65+1.5*55+1.5*35= 297.5 miles.
The average speed is: 297.5/5.5 = 54.09 MPH

Question 4

All saving accounts have different interest rates based on the deposit amount. In one bank for example, if the deposit is 1000 dollars or less, the interest rate is 1% per year, otherwise the interest rate is 2% per year. Write a program that inputs deposit amount. Program calculates and prints the amount of money that will be in your saving account after one year. Apply the interest rate rule which is described above. Bonus: Program checks first, that the input is valid (deposit amount is positive) For invalid input, program prints error message.

Question 5 (pay attention, its similar to mini quiz 2 but also has tax)

Write a program that calculates the total cost of amusement park ticket.

Input: full price of the ticket (integer), age of the person (integer), tax (integer).

Output: Total price after discount and taxes are taken in account. TAX APPLIED AFTER DISCOUNT.

Ticket Price Rules:

Assume that input is valid.