154k views
2 votes
A wind turbine can have 2, 3, or 4 blades. The more blades, the higher the power of the turbine. Write a function with one input and no outputs, where the input is the number of blades. Use a switch statement to write to the screen Low Power Medium Power or High Power where "Low Power" corresponds to 2 blades, "Medium Power" corresponds to 3 blades, and "High Power" corresponds to 4 blades.

User NSGangster
by
5.6k points

1 Answer

4 votes

Answer:

MATLAB Script:

close all

clear

clc

fprintf('Number of blades = 2:\\-------------------------\\')

power(2)

fprintf('\\Number of blades = 3:\\-------------------------\\')

power(3)

fprintf('\\Number of blades = 4:\\-------------------------\\')

power(4)

function power(n)

switch n % n = number of blades

case 2

disp('Low Power')

case 3

disp('Medium Power')

case 4

disp('High Power')

otherwise

disp('Invalid number of blades')

end

end

Step-by-step explanation:

User Cees Timmerman
by
4.3k points