Write function snow that has one parameter, the number of days. The function reads the amount of snow (in inches) for each day and finds and RETURNS the total amount of snow and the average amount of snow per day
Write main that reads the number of days to process and use function snow to find total amount of snow and the average amount of snow per day.
Continuing Problem 1, write different main to perform the following: main reads the number of years to process, then for each year the program reads the number of days to process and finds the total amount of snow and the average amount of snow per day for each year. The program also finds the total amount for all years and the average amount PER YEAR.
Student is taking an exam that has 2 categories: MATH and English. There are several questions in each category. It is a multiple-choice exam, and the answers for all questions are NON-ZERO integes. The maximal number of choices for each question is 5 and the minimal is 1. We will assume that the input will be valid. If student entered ZERO it will be counted as SKIPPED question and get negative score(see the table below). You don't need to know what is the actual question, you only need to know the student answer and the correct answer and calculate the score based on the following tables below. Pay attention: THERE IS A PENALTY for wrong answers and skipping questions.
Correct Answer: | 3 points |
Wrong Answer : | -1 points |
Skipped Question (Zero answer) : | -0.5 |
Correct Answer: | 5 points |
Wrong Answer : | -2 points |
Skipped Question (Zero answer) : | -1 |
Design:
Some store has a ONE-DAY sale with the following rules: if the customer purchasing the items before 2 pm there are two possible disounts: 20 dollars off, if the customer is purchasing for $50 or more or 20% off the entire purchase. If the customer arrives after 2 pm there is only 20% discount. Write a function final_price that has 2 parameters: number of items the customer is purchasing and arrival time(integer, assume that time is entered in 24 hr fomat). The function is reading the original price for each item and using the discount rules described above to find and return the final price of the purchase. The function must use the best possible disount available to allow customer to pay the minial price possible. For example, if the customer purchasing time was 10, and the total before discount was 120 dollars, it is better to use 20% discount and not $20 off discount. Write a function store_sales that has one parameter - number of customers who visited the store on the ONE-DAY sale. The function reads the number of items each customer bought and the purchase time. The function finds and returns the total amount of money all customers spend in the store on the ONE-DAY sale and the average purchasing price per ITEM for that day. The function uses function final_price to calculate the final price for each customer. Function also prints the price each customer paid. Write main that reads the number of customers who visited the store and finds the total amount of money all customers spend in the store on the ONE-DAY sale and the average purchasing price per item for that day. Write a few examples of the input/output that you use to test your program
In USA, each state has different rules for license plates. In this program we will assume that all cars in NJ have 6 digit number license plates, all cars in NY have 7 digit number license plates , and all cars in RI have 4 or 5 digit number license plates. Your program will read a number of cars in the parking lot, license plate for each car, and finds the number of cars from each of the 3 states listed above (NJ, NY, RI). Write the following functions: count_digit(num) - finds and returns the number of digits of the parameter num. Assume that num is positive. state(license_plate) - has one parameter - license plate. The function returns 1, if the car from NJ, 2 - from NY, 3 - from RI. This function will use function count_digit parking(num_cars) - has one parameter, number of cars in the parking lot. The function reads the license plate for each car in the parking lot. The function finds and returns three values: the number of cars from NJ, NY and RI. This function will use function state to determine the state for each car write main that reads the number of cars and finds the number of cars from each of the 3 states listed above (NJ, NY, RI). Pay attention: your input for license plate number could be ANY POSITIVE INTEGER. And your program will ignore any numbers that are shorter than 4 digits and longer than 7 digits since they don't belong to any state.
For short-term investors who plan to buy, fix up and sell their properties right away, usually the following the after-repair-value formula is used:
purchase_price = 75% * (after_repair_value) - repair_expenses
In this formula, after_repair_value is the price that you can sell your home AFTER it is all fixed up.
Example: You see an older home on the market that is visibly rundown and needs repair, and the current market price is: $160,000 "as is." After you assess the damage, you estimate it will require $25,000 repair expenses. Homes of the same size in the neighborhood have been selling for $220,000 in "move-in, turn-key condition." You would need to buy the home for $140,000 to make it a worthwhile investment. (75 percent of $220,000 = $165,000. $165,000 minus $25,000 = $140,000.)
Write the following functions.
The function will use the the formula written below to calculate the purchase price:
purchase_price = 75% * (after_repair_value) - repair_expenses
The function returns the purchase price