write a script that with 3 inputs percentages values calulates the amount based on the first input data in matlab

Here's a script that takes three percentage values as input and calculates the actual amounts based on the first input data in MATLAB:

main.m
% Take percentage values as input
p1 = input("Enter percentage 1: ");
p2 = input("Enter percentage 2: ");
p3 = input("Enter percentage 3: ");

% Calculate amounts
amount1 = p1 * data / 100;
amount2 = p2 * data / 100;
amount3 = p3 * data / 100;

% Display results
fprintf("Amount 1: %.2f\n", amount1);
fprintf("Amount 2: %.2f\n", amount2);
fprintf("Amount 3: %.2f\n", amount3);
377 chars
15 lines

In this code, data represents the first input data. The script prompts the user to enter three percentage values (p1, p2, and p3), and then calculates the corresponding amounts based on the formula: amount = (percentage * data) / 100. It then displays the results using fprintf().

related categories

gistlibby LogSnag