Anda di halaman 1dari 3

Punjab University College of Information Technology

Programming Fundamentals – MSC CS Fall-17


Lab-06

Perform the following tasks in Visual Studio 2010. The program name should be same as
the task name i.e. program name for the first task will be 03-0101. You must choose
meaningful variable names. Your code must be properly indented. You are not allowed to
discuss your problems with your fellows. If you feel any problem in understanding then
you may ask your teacher or TA.

Task: 03-0101
Write a program that accepts as input the mass, in grams, and the density, in grams per
cubic centimeters and outputs the volume of object using the formula: density = mass /
volume.

Task: 03-0201
Write a program that calculates and prints the monthly paycheck for an employee. The
net pay is calculated after taking the following deductions:

Federal Income: 15%


State Tax: 3.5%
Social Security Tax: 5.75%
Medicare Tax: 2.75%
Pension Plan: 5%
Health Insurance: Rs. 200

Your program should prompt the user to input the gross amount and the employee name.
The output should be shown like the following:

Ahmad_Ali
-----------------------------------------
Gross Salary: Rs. 30000
Federal Income: Rs. 4500
State Tax: 1050
Social Security Tax: Rs. 1725
Medicare Tax: Rs. 825
Pension Plan: Rs. 1500
Health Insurance: Rs. 200
------------------------------------------
Net Salary: Rs. 24609
------------------------------------------

Task: 03-0301
Write a program that accepts as input a character and displays the ASCII value of that
character and the next two characters.
Task: 03-0401

Page 1 of 3
Punjab University College of Information Technology
Programming Fundamentals – MSC CS Fall-17
Lab-06
Write a program that asks user to enter the monthly costs for the following expenses
incurred from operating his or her automobile: loan payment, insurance, gas, oil, tires and
maintenance. The program should then display the total monthly cost of these expenses,
and the total annual cost of these expenses.

Task: 03-0501
A milk carton can hold 3.78 liters of milk. Each morning, a dairy farm ships cartons of
milk to a local grocery store. The cost of producing one liter of milk is $0.38 and profit of
each carton of milk is $0.27. Write a program that does the following:
 Prompt the user to enter the total amount of milk produced in the Moring
 Outputs the number of milk cartons needed to hold milk
 Output the cost of producing milk
 Outputs the profit for producing milk

Task 6

Write a program that asks user for an angle, entered in radian. The program should then
display the sine, cosine, and tangent of the angle (use the sin, cos, and tan library
functions) the output should be display in fixed-point notation, rounded to four decimal
places of precision.

Task 7

Write a program that generates and prints a random number between 1 to 100.

Task 8

Write a program that reads an integer and determines and prints whether it is odd or even.
1-(Special Instruction: Use simple division)
2- use modulus operator

Task9.

Write a program that reads two integers (in any order) and then print either “multiple” or
“not” according to weather one of the integer is multiple of other.

Task 10

Calculate pay of an employee based on the hours worked. The input includes the
employee total hours worked this week and their hourly pay rate. The employee is to be
paid their basic wage for the first 40 hours worked and time-and-a-half (i.e. 50% more)
for all hours above 40 (overtime pay). Output the regular pay, overtime pay, and total pay
for the week on the screen. If the employee worked 40 hours or less, do not output any
information about overtime pay.

Page 2 of 3
Punjab University College of Information Technology
Programming Fundamentals – MSC CS Fall-17
Lab-06
Task 11

Write an if-else statement that outputs the word “Warning” provided that
either the value of the variable temperature is greater than or equal to 100, or
the value of the variable pressure is greater than or equal to 200, or both.
Otherwise, the if-else statement outputs the work “OK”. The variables
temperature and pressure are both of type Integer.

Page 3 of 3

Anda mungkin juga menyukai