Programming Fundamentals
Programming Fundamentals
Programming Day 2
Instructor: Registration Number:
Dr. Samyan Qayyum Wahla
___________________________________________
Name:
___________________________________________
Problem Solving
Analyze the given problems according to all the analysis steps given in Problem Set 1. Write down the pseudo code on page
with analysis, draw flow chart and execute it on RAPTOR.
1. Prompt the user to input the elapsed time for an event in seconds. The program then outputs the elapsed time in
hours, minutes, and seconds. (For example, if the elapsed time is 9630 seconds, then the output is 2:40:30.)
2. Prompt the user to input the elapsed time for an event in hours, minutes, and seconds. The program then outputs the
elapsed time in seconds.
3. (Hard drive storage capacity) If you buy a 40GB hard drive, then chances are that the actual storage on the hard
drive is not 40GB. This is due to the fact that, typically, a manufacturer uses 1000 bytes as the value of 1K bytes,
1000K bytes as the value of 1MB, 1000MB as the value of 1GB. Therefore, a 40GB byte hard drive contains
40,000,000,000 bytes. However, in computer memory, 1KB is equal to 1024 bytes, and so on. So the actual storage
on a 40GB hard drive is approximately 37.25GB. (You might like to read the fine print next time you buy a hard
drive). Prompt the user to enter the size of the hard drive specified by the manufacturer, on the hard drive box, and
outputs the actual storage capacity of the hard drive.
4. 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 the profit of each carton of milk is $0.27. Write a program that
does the following:
• Prompts the user to enter the total amount of milk produced in the morning.
• Outputs the number of milk cartons needed to hold milk. (Round your answer to the nearest integer.) Outputs
the cost of producing milk.
• Outputs the profit for producing milk.
5. You found an exciting summer job for five weeks. It pays, say, $15.50 per hour. Suppose that the total tax you pay
on your summer job income is 14%. After paying the taxes, you spend 10% of your net income to buy new clothes
and other accessories for the next school year and 1% to buy school supplies. After buying clothes and school
supplies, you use 25% of the remaining money to buy savings bonds. For each dollar you spend to buy savings
bonds, your parents spend $0.50 to buy additional savings bonds for you. Write a program that prompts the user to
enter the pay rate for an hour and the number of hours you worked each week. The program then outputs the
following:
• Your income before and after taxes from your summer job.
• The money you spend on clothes and other accessories.
• The money you spend on school supplies.
• The money you spend to buy savings bonds.
• The money your parents spend to buy additional savings bonds for you.
6. One metric ton is approximately 2205 pounds. Write a program that prompts the user to input the amount of rice, in
pounds, in a bag. The program outputs the number of bags needed to store one metric ton of rice.
What to Submit: Make two folders for Problem Solving. Zip it and submit it on eduko.