P. 1


|Views: 50|Likes:

More info:

Published by: Gopinath Ulaganathan on Jan 03, 2012
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less





TCP1231 Computer Programming I Trisemester II, 2011/2012 Assignment Questions 7th November 2011

=====================================================================  This assignment is to be done individually. STRICTLY NO COPYING from other students or from any other sources (Internet, books, etc.). Plagiarism and cheating is an offence! If you fail to prove that you have done the assignment on your own, you will be given a mark of ZERO.   There are 15 questions available in this list. You are required to select only one question and follow the Submission Guidelines for assignment completion. Due date: The assignment must be submitted to your respective tutor in Week 7, on 29th

November 2011, by 5pm. 5% of the full marks shall be deducted for every 24 hours (1 day) delay.  Assignment demonstration will be conducted in Week 7 during lab session, by 2nd December 2011.

Assignment 1 Registration  Go to http://ipms.site90.com/tcp1231 and login using the following credential to register your question number. Login ID: tcp1231_2011a1 Password: mmu_fist1992  Enter your student ID and select the question number. The assignment questions are available based on first come first serve manner. One question cannot be selected by more than 3 students.   If your student ID does not exist in the database, then please inform me immediately. You must select and register online by 14 November 2011. The objective of this project is to test the skill of the students in problem solving and modular design using algorithms, pseudo-code, and flowcharts. The students are expected to implement the program in C++ language. =====================================================================

1 General Appearance of Program (display) 6. user-friendliness) 6.5 Error-Handling Coding 5.3 A virus-free floppy disk/CD containing the softcopy of your report and source code.2 Program Source Code with Comments (printed version) 6.2 Accuracy (program works and runs correctly) 6.4 Performs All Required Features 6.2 Code Strategy 5. logics.1 User Manual with Sample Screen Shots 6.Program demonstration session by each student (presenting your work to your tutor) Program Execution If the program cannot run (even if it can compile).5 Error-free During Runtime TOTAL Bonus Code Modularity (usage of functions) Additional special features OR any other significant contributions Marks Your Marks 1 2 3 4 2 (20) 5 6 6 3 (35) 12 12 6 3 2 (13) 8 3 2 5 6 7 8 (30) 5 10 5 5 5 100 5 5 9 Error-handling: Code Modularity: Accuracy: Code Efficiency: Code Strategy: The program should handle special cases such as an accidental invalid input from the user. unnecessary loops).4 Flowcharts 4. .5 Style – Indentation Program Documentation 6.Submission Guidelines: Category Report Cover Page Assignment Assessment Sheet Introduction and Problem Definition (IN YOUR OWN WORDS!!!) Program design 4. how the program will proceed with error detection? Break down the problem into smaller functions.3 Usability (interaction with user.3 Error Checking Features 5.4 Style – Self Documentation 5. and code repetition. computations. Process and Output (other Conditions / Assumptions / Constraints) 4. and variable naming convention. Demonstration . the functions should NEVER be too long. Ensure the accuracy in terms of correct computations and usage of decimal points.2 Algorithms or Pseudocode 4. 0 mark will be given for this section 6. Ensure the proper flow of the program.1 Code Efficiency 5. usage of variables.g. Ensure the usage of control flow (e.1 Input. In case of wrong inputs.

This figure is then multiplied by the loan period of 1. Repayment is made in equal monthly installment based on the face value.the amount the consumer needs to receive . ===================================================================== . each withholding amount.00 by 0. ===================================================================== Question 2 An employee is paid at a rate of $16. From the worker’s gross pay. and the net take-home pay for the week. 14% is withheld for federal income tax. Write a program that will take three inputs: . The program will then output the worker’s gross pay.5 years to yield $225. The amount is immediately deducted from the face value.00.000.56. but the calculation is a bit more complicated if the customer needs $1000. 6% is withheld for social security tax. which is $55. It should also calculate the monthly payment. Hence. Write a program that will read in the number of hours worked in a week and the number of dependents as input. This method of calculation may not be too bad if the consumer needs $775.00 per week is withheld for union dues.000. The interest rate is computed by multiplying the face value of $1.00. the interest rate is 15%. One form of the loan is the discount installment loan. Any hours over that are paid at the overtime rate of one and half times that. leaving the consumer with only $775. Your program should allow the calculation to be repeated as often as the user wishes. If the worker has three or more dependents.00. and the duration is 18 months. 5% is withheld for state income tax.00 dollars.15 to yield $150.00 as the total interest owned. then an additional $35.the interest rate .000.00 is withheld to cover the extra cost of health insurance beyond what the employer pays.the duration of the loan in months The program should then calculate the face value required in order for the consumer to receive the amount needed. and $10.78 per hour for the first 40 hours worked in a week. which works as follows.Question 1 Negotiating a consumer loan is not always straightforward.00 divide by 18. Suppose a loan has a face value $1. the monthly loan payment will be $1.00. Your program should allow the calculations to be repeated as often as the user wishes.

If you owe $50.an interest rate of 18% per year (and hence 1.g. Any call started on Saturday or Sunday is charged at a rate of $0.M. Do not forget the interest on the last payment. The last payment may be less than $50.00.no down payment .00 is used to pay the interest and whatever is left is used to pay the part of the remaining debt.48).00 will not pay off your debt.the time the call started .40 per minute.5% per month) .25 per minute.00.00.M. Use loops to calculate the amount of interest and the size of the dept after each month. b. you can deduct $35.monthly payment of $50. is charged at a rate of $0. which leaves you with a debt of $965.00 is only 75 cents. is billed at a rate of $0. The number of minutes will be input as a value of type int. The input will consist of .00 is deducted from your debt.00 The monthly payment of $50. Monday through Friday. the time 1:30 P. ===================================================================== .. Your program should allow the calculation to be repeated as often as the user wishes.00 on the following credit card plan: . Any call started between 8:00 A. or after 6:00 P. The day of the week will be read as one of the following pairs of character values.M..00 (that is $14. One month’s interest on $50.M.00 in interest). Use a variable to count the number of loop iterations and hence the number of months until the dept is zero. Hence. then your monthly payment of $50.Question 3 You have purchased a stereo system that cost $1000.48) form the amount you owe.15 per minute. The remaining $35.5% of $965.00-$14. The next month you pay interest of 1.M. and 6:00 P.00 in interest (that is $15. The time is to be input in 24-hour notation (e. the first month you pay 1. is input as 13:30). You may want to use other variables as well. c. Hence. The cost of the call is determined according to the following rate schedule: a.52 (which is $50.the day of the week .5% of $1000. which are stored in two variables of type char: Mo Tu We Th Fr Sa Su Be sure to allow the user to use either uppercase or lowercase letters or a combination of the two. although it will come close. Your program should include a loop that lets the user repeat this calculation until the user says she or he is done. Any call starting before 8:00 A.the length of the call in minutes The output will be the cost of the call. ===================================================================== Question 4 Write a program that computes the cost of a long-distance call. Write a program that will tell you how many months it will take you to pay off the loan as well as the total amount of interest paid over the life of the loan. Monday through Friday.

Jacket size (chest in inches) = height times weight divided by 288 and then adjusted by adding 1/8 of an inch for each 10 years over age 30. For example. Make it a single player game where the player plays with the computer. Do not use nickel abd half-dollar coins. but 1/10 of an inch is added for age 30. Hence. Option: Your program may include a loop that lets the user repeat the game until the user says she or he is done. there is no adjustment for ages 30 through 39. if the amount is 86 cents. It then should compute clothing sizes acoording to the formulas: . ===================================================================== .7 and then adjusted by adding 1/10 of an inch for each 2 years over age 28. the output would be something like the following: 86 cents can be given as 3 quarter(s) 1 dime(s) and 1 penny(pennies) Use coin denominations of 25 cents (quarters). ===================================================================== Question 8 Write a program that tells what coins to give out for any amount of change from 1 cent to 99 cents.9. Option: Your program may include a loop that lets the user repeat the game until the user says she or he is done. ===================================================================== Question 6 Develop a simple Tic-Tac-Toe program. but 1/8 of an inch is added for age 40. and age.) .wikipedia. ===================================================================== Question 7 Write a program that asks for user’s height. Include the loop that lets the user repeat this computation for new input values until the user says he or she wants to end the program. . (Note that the adjustment only takes place after a full 10 years. there is no adjustment for age 29.Hat size = weight in pounds divided by heigh in inches and all that multiplied by 2. The party that accumulatively wins 3 times first will win the game. 10 cents (dimes).Waist in inches = weight divided by 5. You can choose to develop a single player (player plays with computer) or two players game.Question 5 Develop a simple Paper-Scissors-Rock program (http://en. and 1 cent (pennies).org/wiki/Rock-paperscissors). (Note that the adjustment only takes place after a full 2 years. Hence. weight.) Your prgram should allow the user to repeat this calculation as often as the user wishes.

21 28: 1.5.. Let us list the factors of the first seven triangle numbers: 1: 1 3: 1. 36.6 10: 1. 2.3 6: 1. 45. etc). Develop a program that inputs a person’s weight. the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. Meet the basal metabolic rate (energy required to breath.2. 21. The computation should include the energy that is required to digest food.3.2)0. an adult human needs to consume enough calories daily to: 1.7. Account for physical activity such as exercise.10 15: 1. For an adult that weights P pounds.3.1 In other words. 15. a double cheeseburger has approximately 1000 calories. Hence.756 2.14.28 We can see that 28 is the first triangle number to have over five divisors. The first ten terms would be: 1.3. 6. 55. maintain body temperature. For example. Physical activity: Calories required = 0.2.2. minutes spent execersing.0385*Intensity*P*Minutes Minutes: Number of minutes spent during the physical activity Intensity: A number that estimates the intensity of the activity Here are some sample numbers for the range of values: Activity Intensity Running 10 mph: 17 Running 6 mph: 10 Basketball: 8 Walking 1 mph: 1 3.Question 9 To maintain one’s body weight. What is the value of the first triangle number to have over one hundred divisors? .5. and the number of calories in one serving of your favorite food. You can find estimates of the caloric content of many foods on the web. an estimate of the intensity of physical activity. 10. . The program should then clculate and output how many servings of that food should be eaten per day to maintain the person’s current weight at the specified activity level.4. 3.7. Include the loop that lets the user repeat this computation for new input values until the user says he or she wants to end the program ===================================================================== Question 10 The sequence of triangle numbers is generated by adding the natural numbers. Energy to digest food: calories required = TotalCaloriesConsumed*0. 28. Account for the energy required to digest the food that is being eaten.15 21: 1. we can estimate these caloric requirements using the following formulas: 1. 10% pf the calories we consume goes towards digestion. Basal metabolic rate: Calories required = 70*(P/2. 3..

For any velocities that are on the border of a gear change. Print the velocity and the gear number to the screen. depreciation rate. . The gear in which the bicycle is in depends on the velocity in the following manner. Limit the maximum velocity to 100km/hr. This assumption leads to the following relationship: S = C(1 ─ d)n where C = original cost of assed d = depreciation rate per year n = number of years S = book value of the end of n years. use the lower gear.Question 11 The constant percentage method of computing depreciation of an asset is based on the assumption that the depreciation charge at the end of each year is a fixed percentage of the book value of the asset at the beginning of the year. Question 12 A bicycle accelerates at a constant rate from a stationary position. Write a program to compute the number of years of useful life of an asset given the original cost. and book value at the end of its useful life (called scrap value). The program should also display the book value at the end of each year until the end of its useful life. Your program should allow the user to repeat this calculation as often as the user wishes. Your program should allow the user to repeat this calculation as often as the user wishes. Velocity (km/hour) 0─3 3─5 5─7 7─10 10─12 12─15 15─17 17─21 21─24 24─28 28─35 35─40 40─48 48─55 55─100 Gear 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Write a program to ask user to input an acceleration (km/hour) and the riding time (hh:mm:ss) and determine which gear the bicycle is in at that time.

If there is overlap. 4.1415936. It may be possible for two rectangles to overlap at more than one corner.y) coordinates of the lower left and upper right corners. Question 14 Develop a program that accepts for each faculty member of a small college two data values: faculty salary and a character value for faculty performance level. Write a program to determine whether three given rectangles overlap. otherwise.5 percent. and arccos is the “arc_cosine” function. The performance-level data item can have the values S. Question 15 A rectangle in x─y space can be defined with the (x. angle is in degrees. risky and dangerous zones are defined as follows: Safe zone : angle >= 140 Risky zone : 124 < angle < 140 Dangerous zone : angle <= 124 The program should prompt the user to input a femur length in inches and then computes and prints the safe bench heights. Hint: Try out the case with two rectangles first and analyze all possible overlap cases between two rectangles. and A for superior. 8. plus a merit raise. The program should be able to accept data for any number of faculty members. The bench should not be too high for you.” a degenerative knee condition caused by the grinding of the cartilage between the patella and the femur. Safe. for good performance it is 1. Print out whether or not the rectangles overlap. print out the pairs of overlapping rectangles and the coordinates of the corners of their overlapping region. as well as the maximum allowable bench height that is not considered dangerous.Question 13 A popular form of fitness aerobics makes use of an adjustable-height bench that increases the intensity of aerobics workout without making it high impact. 6. 10 and 12 inches. respectively. Values for femur_length can be integers in the range of 10 to 21 inches. and for average performance no merit raise is given. G. We want the program to compute and display on the terminal screen the cost of a proposed pay increase scheme. Your program should allow the calculation to be repeated as often as the user wishes. The safe bench height depends on your femur length and is determined by the knee angle formed when you stand in front of the bench with one foot on the bench. Merit raise percentages depend on the performance level. One of the important safety factors in bench exercises is the bench height. there is a danger of developing “chondromalacia patellae. The pay increase scheme assumes a 3. for superior performance it is 2. . good. Your program should allow the calculation to be repeated as often as the user wishes.5 percent across-the-board increase for all faculty members. The formula for knee angle in terms of bench_height and femur_length is where  = 3. Values for bench_height can be 2. and average. Have a user input the corners of three rectangles (a total of six x-y) pairs.5 percent.

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->