Vous êtes sur la page 1sur 3

Punjab University College of Information Technology

Programming Fundamentals
Lab-04

Task: 01
A mobile phone service provider has three different subscription packages for its customers:
Package A: For $39.99 per month 450 minutes are provided. Additional minutes are
$0.45 per minute.
Package B: For $59.99 per month 900 minutes are provided. Additional minutes are
$0.40 per minute.
Package C: For $69.99 per month unlimited minutes provided.

Write a program that calculates a customers monthly bill. It should ask which package
the customer has purchased and how many minutes were used. It should then display the
total amount due.
It also displays how much money Package A customers would save if they purchased
packages B or C, and how much money Package B customers would save if they
purchased Package C. If there would be no savings, no message should be printed.
Note: Be sure the user only selects package A, B, or C.

Task: 02
Months with 30 days have 720 hours, and months with 31 days have 744 hours.
February, with 28 days, has 672 hours. You can calculate the number of minutes in a month by
multiplying its number of hours by 60. Enhance the input validation of the Mobile Service
Provider program by asking the user for the month (by name), and validating that the number of
minutes entered is not more than the maximum for the entire month. Here is a table of the
months, their days, and number of hours in each.
Month Days Hours

January 31 744
February 28 672
March 31 744
April 30 720
May 31 744
June 30 720
July 31 744
August 31 744
September 30 720
October 31 744
November 30 720
December 31 744

Task: 03
Running on a particular treadmill you burn 3.6 calories per minute. Write a program that uses a
loop to display the number of calories burned after 5, 10, 15, 20, 25, and 30 minutes.

Task: 04
The distance a vehicle travels can be calculated as follows:
Distance = speed * time
For example, if a train travels 40 miles per hour for 3 hours, the distance traveled is 120 miles.
Write a program that asks the user for the speed of a vehicle (in miles per hour) and how many
hours it has traveled. The program should then use a loop to display the distance the vehicle has
traveled for each hour of that time period.
Here is an example of the output:
What is the speed of the vehicle in mph? 40
How many hours has it traveled? 3
Hour Distance Traveled

1 40
2 80
3 120

Note: Do not accept a negative number for speed and do not accept any value less than 1 for
time traveled.

Task: 05
Assuming the oceans level is currently rising at about 1.5 millimeters per year, write a program
that displays a table showing the number of millimeters that the ocean will have risen each year
for the next 10 years.

Task: 06
Write a program that asks the user to enter the month (letting the user enter an integer in the
range of 1 through 12) and the year. The program should then display the number of days in that
month. Use the following criteria to identify leap years:
1. Determine whether the year is divisible by 100. If it is, then it is a leap year if and only if it is
divisible by 400. For example, 2000 is a leap year but 2100 is not.
2. If the year is not divisible by 100, then it is a leap year if and if only it is divisible by 4. For
example, 2008 is a leap year but 2009 is not.
Here is a sample run of the program:
Enter a month (1-12): 2 [Enter]
Enter a year: 2008 [Enter]
29 days

Vous aimerez peut-être aussi