Lab Practice

  1. Test 2 Preparation

  2. Write the answer to the following problem . Explain your answer.

  3. Write the answer to the following problem . Explain your answer.

  4. Write a program that reads temperature for one day and rain/no rain indicator for that day. (0 - NO RAIN, 1 - RAIN). The program checks if it was a warm day (temperature is at least 75) with no rain.

  5. Work commute requires crossing the bridge. The bridge cost is defined below in Table 1 (for vehicles WITHOUT EZ PASS) and Table 2 (for vehicles WITH EZ PASS).

    TABLE 1: Bridge Cost NO EZ PASS

    CAR TYPE: COST
    1 : $5
    2 : $6

    TABLE 2: Bridge Cost EZ PASS

    CAR TYPE: COST
    1 : $4.5
    2 : $4.5

    Suppose, TWO people in the family are crossing the bridge TWICE per day (to go to work and come back from work) and the payment is required in both directions. Write a program that reads car type and EZ pass indicator for each family member and calculates the total cost of work commute per family. Car type could be 1 or 2, 1 for regular car and 2 for track or bus, and EZ pass indicator, that could be 0 ( no ez pass) or 1 (there is ez pass). ASSUME THE INPUT IS VALID!

    Example: Input: 1 1 2 0 Output: 21 dollars (explanation: one way cost 10.5 = 4.5+6, and both ways will cost 10.5*2 = 21 dollars)

  6. A Holiday Sale in one of the department stores has the following rules. All items receive a 30% discount except home and electronics. Home items receive 15% and electronics 10%. We will assume that ALL items are NOT taxable. In addition, if the discounted total is 40 dollars or more, an additional 10 dollars off is applied. We will assume that the user is purchasing 3 items. For each item, the program reads the price and the category. We will use the following category indicators: Home = 1, Electronics = 2, Everything else = 3. Write a program that finds the final purchase amount.

    Example 1: input (price and category for each item): 32.50, 1, 12.99, 2, 3.49, 3 Output: 31.76 (explanation: 32.5 received 15% discount, 12.99 received 10% discount, and 3.49 received 30% discount. The total after discount is taken is 41.76 dollars. Since this is over 40 dollars, an additional 10 dollars off is applied and the final total is 31.76)

    Example 2: input: 15.99, 2, 10.99, 1, 1.99, 3 Output: 25.13

  7. In college, there are certain requirements for various courses. For example, Value Seminar in our school requires junior or senior standing. In our school to graduate the student needs to complete at least 121 credits. The standing status for each year is defined as follows for College of Arts and Sciences in our school:

    • To be considered Sophomore, student needs to complete at least 26 credits
    • To be considered Junior, student needs to complete at least 57 credits
    • To be considered Senior, student needs to complete at least 88 credits.

    Write a program that reads number of credits student took so far and the 3-digit course number student would like to take. The program prints eligibility message for the student.
    Assume that input is VALID

    Use the following rules:

    • Freshman students are eligible to take all 100 Level Courses ONLY
    • Sophomore students are eligible to take all 100 and 200 level courses ONLY
    • Junior students are eliguble to take all 100, 200 and 300 level courses ONLY
    • Senior students are eligible to take ALL COURSES