Question

Using the Design Recipe, write an algorithm for each of the following programming problems, showing all...

Using the Design Recipe, write an algorithm for each of the following programming problems, showing all work (i.e., Contract, Purpose Statement, Examples and Algorithm):

5.Write a program that reads two times in military format (e.g., 0900, 1730) and prints the number of hours and minutes between the two times. Note that the first time can come before or after the second time.

6.An online bank wants you to create a program that shows prospective customers how their deposits will grow. Your program should read the initial balance and the annual interest rate. Interest is compounded monthly. Print out the balance for each of the first three months.

7.A video club wants to reward its best members with a discount based on the member’s number of movie rentals and the number of new members referred by the member. The discount is in percent and is equal to the sum of the rentals and the referrals, but it cannot exceed 75 percent. The program shows the user the discount rate awarded.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

5.

Algorithm:

TimeDifference(time1,time2):

{

time1Hour=time1/100

time1Min=time1%100

time2Hour=time2/100

time2Min=time2%100

if(time1>time2)

{

diffHour=time1Hour-time2Hour

diffMin=time1Min-time2Min

if(diffMin<0)

{

diffMin=diffMin+60

diffHour=diffHour-1

}

}

else

{

diffHour=time2Hour-time1Hour

diffMin=time2Min-time1Min

if(diffMin<0)

{

diffMin=diffMin+60

diffHour=diffHour-1

}

}

return(diffHour*60+diffMin)//return difference in minutes

}

6.

Algorithm:

CalculateInterest(balance,rate):

{

for i=1 to 3

{

balance=balance+(balance*rate)

print("Balance after month "+i+" is"+balance)

}

}

7.

Algorithm:

CalculateDiscount(rental,referal):

{

discount=rental+referal

if(discount>75)

discount=75

print(discount)

}

Add a comment
Know the answer?
Add Answer to:
Using the Design Recipe, write an algorithm for each of the following programming problems, showing all...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • SYNOPSIS The product manager for coffee development at Kraft Canada must decide whether to introduce the...

    SYNOPSIS The product manager for coffee development at Kraft Canada must decide whether to introduce the company's new line of single-serve coffee pods or to await results from the product's launch in the United States. Key strategic decisions include choosing the target market to focus on and determining the value proposition to emphasize. Important questions are also raised in regard to how the new product should be branded, the flavors to offer, whether Kraft should use traditional distribution channels or...

  • CASE 20 Enron: Not Accounting for the Future* INTRODUCTION Once upon a time, there was a...

    CASE 20 Enron: Not Accounting for the Future* INTRODUCTION Once upon a time, there was a gleaming office tower in Houston, Texas. In front of that gleaming tower was a giant "E" slowly revolving, flashing in the hot Texas sun. But in 2001, the Enron Corporation, which once ranked among the top Fortune 500 companies, would collapse under a mountain of debt that had been concealed through a complex scheme of off-balance-sheet partnerships. Forced to declare bankruptcy, the energy firm...

  • Case: Enron: Questionable Accounting Leads to CollapseIntroductionOnce upon a time, there was a gleaming...

    Case: Enron: Questionable Accounting Leads to CollapseIntroductionOnce upon a time, there was a gleaming office tower in Houston, Texas. In front of that gleaming tower was a giant “E,” slowly revolving, flashing in the hot Texas sun. But in 2001, the Enron Corporation, which once ranked among the top Fortune 500 companies, would collapse under a mountain of debt that had been concealed through a complex scheme of off-balance-sheet partnerships. Forced to declare bankruptcy, the energy firm laid off 4,000...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT