You must write name header on the top of every
homework assignment. (It will include your name, id,
Note: In all these exercises, pay attention on
documentation. User has no idea about your code and your algorithm. Keep your output “user
friendly” so that user can understand what s/he is doing.
Exercise 1: (Average Rainfall)
Write a program that uses nested loops to collect data and calculate the average rainfall over a
period of years. The program should first ask the number of years. The outer loop will iterate once
for each year. The inner loop will iterate twelve times, once for each month. Each iteration of the
inner loop will ask the user for the inches of rainfall for that month. After all iterations, the program
should display the number of months, the total inches of rainfall, and the average rainfall per month
for the entire period.
Exercise 2: (Pennies for a day)
Write a program that calculates the amount of money a
person would earn over a period of time if his or her
salary is one penny for first day, two pennies for the
second day, and continues to double each day. The
program should ask the user for the number of days.
Display a table showing what the salary was for each
day, then show the total pay at the end of the period.
The output should be displayed in a dollar amount, not
the number of pennies.
Exercise 3: (Stadium Seating)
There are three seating categories at a stadium. Class A seats cost $20, Class B seats cost $15, and
Class C seats cost $10. Write a program that asks how many tickets for each class of seats were
sold, then displays the amount of income generated from ticket sales.
(Design your code anyway you like. Try to break your program into functions.)
Exercise 4: (Test Average and Grade)
Write a program that ask the user to enter five test scores. The program should display a letter
grade for each score and the average test score. Write the following function in the program.
calc_average. This function should accept five test scores as
arguments and return the average of the scores.
determine_grade. This function should accept a test score as an
argument and return a letter grade for the score based on the
following grading scale.
Exercise 5: (Triangle Pattern)
Ask the user, how many
rows he/she wants to print
in a triangle.
Make sure, this number
must be greater than 1
(You need at least two
rows for triangle).
Print the triangle with this
row number and last row
should have that many stars.
Exercise 6: (Loan qualifier)
This program determines whether a bank customer qualifies for a loan or not. If the customer
salary is more than or equal to 30,000 and his/her number of years on job is more than or equal
to two years, s/he qualifies for the loan.
You must write a function which accepts salary and number of years as argument.
Must do input validation, salary can’t be zero or less than zero.
Number of years on job can’t be negative.
Your code must loop for both input separately until you get the salary and number of year
Below 60 F