Presentation is loading. Please wait.

Presentation is loading. Please wait.

Program Planning & Design. Hierarchy Charts Salary Calculator Annual RaiseBonusLeaveDeductions One timeDistributed PaidUnpaidSick FixedOne time.

Similar presentations


Presentation on theme: "Program Planning & Design. Hierarchy Charts Salary Calculator Annual RaiseBonusLeaveDeductions One timeDistributed PaidUnpaidSick FixedOne time."— Presentation transcript:

1 Program Planning & Design

2 Hierarchy Charts Salary Calculator Annual RaiseBonusLeaveDeductions One timeDistributed PaidUnpaidSick FixedOne time

3 Pseudo Code More human-language type Multiplication question 1.Generate a pair of random numbers ‘a’ and ‘b’ between 1 and 16. Ensure that this pair has not been used already. 2.Ask the user to enter the answer to a x b and save a & b 3.Give 3 chances to the user to answer correctly. Give the correct answer if the user failed in all attempts and record this pair as a repeated error. 4.Repeat 1 – 3 till the user types ‘END’. 5.Print all repeated error pairs with correct answers. Can you find a flaw?

4 Flow Charts Processing Step Terminator Start & End Connector Data In or Out Off page Connector Decision

5 Problem Understanding Get a pair of numbers from the user, add them and display the result on monitor. –Integer, Real or Complex numbers Representation of Complex numbers –Rectangular or polar representation? Divide a number by another number and write the result on monitor.

6 User Interface User of a computer is not necessarily a computer scientist or engineer –Make the users learn CS/CE?  –Who will hire CS/CE majors?  –Design programs that are user friendly –More jobs for CS/CE

7 Documentation Try to understand the following code T = A A = B B = T

8 Documentation Try to understand the following code ‘Select the bigger of the two numbers If (numberA < numberB) then choice = numberB Else choice = numberA End If Comment line

9 Example A factory gives a sale incentive to its dealers as follows. A monthly sale of Rs 5,000 is the break even point and is not eligible for any incentive. For the amount above Rs. 5,000 but below Rs. 20,000, the incentive is fixed at 5% of the “eligible amount”. The eligible amount is found by subtracting Rs. 5,000 from the monthly sale figure. Incentive rate steps up by 2% for every additional Rs 10,000 sale, beyond the Rs. 20,000 sale. The total incentive received by a dealer is capped at a yearly maximum of Rs. 19,900. Write a computer program that computes the monthly incentive for a dealer, given his/her sale amount for a month.

10 Solution: Incentive Calculations First MethodSecond Method If the total sale is above Rs. 20,000 in a month then use the highest rate to the total eligible amount. For example, a sale of Rs.39,000 has Rs34,000 as eligible amount. The maximum rate is 7%. Thus the incentive is Rs.2,380 for that month. Use 5% incentive rate on the eligible amount for sales up to Rs. 20,000. For a total sale beyond this use incremental incentive rate. For a sale of Rs. 39,000, we use 5% rate for the first Rs. 20,000 sale and 7% for the additional Rs. 19,000. Thus the total incentive is 5% of 15,000 + 7% of 19,000 = 750 + 1,330 = Rs.2,080

11 Incentive: Pseudo Code Get the name or identity of the dealer. Get YearIncentive given to that dealer so far and the MonthSale. Set MonthIncentive=0 If (YearIncentive is less than 19,900 AND MonthSale is more than 5000) then Calculate Incentive for current month TotalIncentive = YearIncentive + Incentive MonthIncentive=Incentive If (TotalIncentive > 19,900) MonthIncentive = 19,900- YearIncentive TotalIncentive = 19,900 End If YearIncentive=TotalIncentive Save YearIncentive End If Display MonthIncentive Stop

12 Flow Chart Start Read MonthSale & YearIncentive YearIncentive < 19,900 And MonthSale > 5000 MonthIncentive=0 Calculate Incentive and save results No Yes A B 1

13 Flow Chart Display MonthIncentive STOP 1


Download ppt "Program Planning & Design. Hierarchy Charts Salary Calculator Annual RaiseBonusLeaveDeductions One timeDistributed PaidUnpaidSick FixedOne time."

Similar presentations


Ads by Google