Write an algorithm for a program that can be used to determine the tip amount that should be added to a restaurant charge. Allow the user to input the total, before taxes and the tip percentage (15% or 20%). Produce output showing the calculated values including the total amount due for both the 15% and the 201% tips. Tax of 9% should be added to the bill before the tip is determined. Display subtotal showing the amount owed prior to applying the tip, show each tip amount and the totals with each tip amount. Be sure to provide labels for values and the totals with each tip amount. Write appropriate methods for your solution.
Start function calculateTip15( billAmount)
return billAmount * 0.15
End
Start function calculateTip20(billAmount)
return billAmount * 0.2
End
Start function calculateTax(billAmount)
return billAmount * 0.09
End
Start method Main()
Declare variables billAmount,tax ,subtotal,tip15,tip20,totalAmountDue
Print "Enter the bill amount: "
Read billAmount
Set tax = calculateTax(billAmount)
Set subtotal = billAmount + tax
Set tip15 = calculateTip15(subtotal)
Set tip20 = calculateTip20(subtotal)
Set totalAmountDue = subtotal + tip15 + tip20
Print "The subtotal (the amount owed prior to applying the tip): "+ subtotal
Print "Tax of 9%: "+ tax
Print "The total amount due for the 15% tips: "+ tip15
Print "The total amount due for the 20% tips: "+ tip20
Print "The total amount due: "+ totalAmountDue
End
Comments
Leave a comment