Tip Before Tax or After? Script same: compareTips Script Outputs (3): - tipBefor
ID: 3636777 • Letter: T
Question
Tip Before Tax or After? Script same: compareTips Script Outputs (3): - tipBefore (double) the tip arount before tax - tipAfter (double) the tip amount after tax - difference (double) the absolute difference between the two Script Description: Several TAs went to dinner and were having a discussion about whether its better to tip before tax or after, and what the actual difference in the amount paid is. Given their subtotal of the meal, the sales tax percentage, and the percentage of the tip, write a script called "compareTips" that computes the tip before sales tax is applied, after sales tax is applied, and the difference between the two. Name your variables "tipBefore", "tipAfter", and "difference" respectively. Notes: - YOU do not have to account for rounding to the nearest penny. Inputs: subtotal: $101.68 sales tax percentage: 9.75% tip percentage: 20% Outputs: tipBefore rightarrow 20.3360 - tipAfter rightarrow 22.3188 difference rightarrow 1.9828Explanation / Answer
Here is your code. -------------------------- sub=input('Subtotal:'); st=input('Sales tax percentage:'); tip=input('Tpip percentage:'); tipbefore=sub*tip/100; tipafter=(sub+(sub*st/100))*tip/100; diff=tipafter-tipbefore; printf('TipBefor => %f',tipbefore); disp(' '); printf('TipAfter => %f',tipafter); disp(' '); printf('Difference => %f',diff); I hope that this solves your problem.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.