Question: % Prompt the user for the bill amount billAmount = input ( ' Enter the bill amount: ' ) ; % Prompt the user for

% Prompt the user for the bill amount
billAmount = input('Enter the bill amount: ');
% Prompt the user for the quality of service
serviceQuality = input('How was the service? (1- good, 2- average, 3- bad): ','s');
% Initialize variables for tip percentage and total amount
tipPercentage =0;
totalAmount =0;
% Determine the tip percentage based on service quality
if strcmp(serviceQuality,'1')% Good service
tipPercentage =0.20; %20% tip
elseif strcmp(serviceQuality,'2')% Average service
tipPercentage =0.18; %18% tip
elseif strcmp(serviceQuality,'3')% Bad service
tipPercentage =0.15; %15% tip
else % Invalid input
fprintf('Invalid input. Please enter 1,2, or 3.
');
return; % Exit the script
end
% Calculate the total amount including the tip
totalAmount = billAmount +(billAmount * tipPercentage);
% Display the formatted total amount
fprintf('The total bill including tip is: $%.2f
', totalAmount);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!