Write a program that continues to prompt the user until the

Write a program that continues to prompt the user (until the user quits) if he/she wants the computer to randomly generate an integer between 1 and 12 and displays the English month name January, February, ...., December for the number 1, 2, .... 12, accordingly. (Check the sample output below). Input Data None Output Data English name for the month (randomly generated) Getting Started In Command Window type edit randomMonth_yourLastName.m. You will be prompted that the file does not currently exist; select okay. MATLAB will open the file in the editor. Include header comments formatted as show below:

Solution

% matlab code random month
while true
month = randi([1, 12]);
if month == 1
disp(\"January\ \");
elseif month == 2
disp(\"February\ \");
elseif month == 3
disp(\"March\ \");
elseif month == 4
disp(\"April\ \");
elseif month == 5
disp(\"May\ \");
elseif month == 6
disp(\"June\ \");
elseif month == 7
disp(\"July\ \");
elseif month == 8
disp(\"August\ \");
elseif month == 9
disp(\"September\ \");
elseif month == 10
disp(\"October\ \");
elseif month == 11
disp(\"November\ \");
elseif month == 12
disp(\"December\ \");
else
disp(\"Invalid month\ \");
end
  
choice = input(\"Do you want to continue(y or n)? \",\'s\');
if choice == \'n\'
break;
end
end

%{
output:

October

Do you want to continue(y or n)? y   
January

Do you want to continue(y or n)? y   
December   

Do you want to continue(y or n)? y   
December   

Do you want to continue(y or n)? n

%}

 Write a program that continues to prompt the user (until the user quits) if he/she wants the computer to randomly generate an integer between 1 and 12 and disp
 Write a program that continues to prompt the user (until the user quits) if he/she wants the computer to randomly generate an integer between 1 and 12 and disp

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site