This is matlab problems. Can you do it and send me codes thanks. mytipcalculator
ID: 3209973 • Letter: T
Question
This is matlab problems. Can you do it and send me codes thanks.
Explanation / Answer
mytipcalculator.m
close all
clear
clc
bill = input('what is the total bill? ');
num_people = input('how many people are in your party? ');
if num_people <= 6
tip = 15;
elseif num_people <= 8
tip = 18;
elseif num_people <= 11
tip = 20;
else
tip = 25;
end
fprintf('your calculated tip is $%.2f ', tip*0.01*bill);
sample output
what is the total bill? 79
how many people are in your party? 5
your calculated tip is $11.85
exptaylorseries.m
close all
clear
clc
x = input('enter a value of x: ');
actual = exp(x);
tol = 0.00001;
s = 0; n = 0;
while 1
s = s + x^n/factorial(n);
if abs(actual - s) <= tol
fprintf('the difference between the actual value exp(x) and the Taylor Series expansion is %.12f ', abs(actual - s));
fprintf('the loop iterated %d times ', n);
break;
end
n = n + 1;
end
sample output
enter a value of x: 16
the difference between the actual value exp(x) and the Taylor Series expansion is 0.000007281080
the loop iterated 51 times
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.