Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %Mason Marnell - Assignment 3
- % remember, don't just deadass copy paste pls
- %%
- %Question 1
- dept = menu("Select what Engineering Deparptment you are in: ", 'Civil Engineer','Chemical Engineer','Computer Engineer','Electrical Engineer','Mechanical Engineer');
- CredHours = 0;
- disp(dept);
- switch dept
- case 1
- CredHours = 135;
- case 2
- CredHours = 135;
- case 3
- CredHours = 125;
- case 4
- CredHours = 130;
- case 5
- CredHours = 128;
- end
- fprintf('You need a minimum of %d credit hours',CredHours);
- %%
- %Question 2
- inp = input("Input X, y/Y, or Q ","s");
- if inp == "X"
- disp("Hello");
- elseif inp == "Y" || inp == "y"
- disp("Yes");
- elseif inp == "Q"
- disp("Quit");
- else
- disp("Error");
- end
- %%
- %Question 3 - switch the code to a switch/case version
- code = lower(input("Input A, B, C , D, or E: ","s"));
- switch code
- case "b"
- fprintf("Every 7 minutes\n");
- case "c"
- fprintf("Every 10 minutes\n");
- case "d"
- fprintf("Every 7 minutes\n");
- case "a"
- fprintf("This line is now obsolete!\n");
- case "e"
- fprintf("Error - there is no such trolley!\n");
- otherwise
- fprintf("Every 12 minutes\n");
- end
- %%
- %question 4
- wind = input("Input the wind speed: ");
- if (wind >= 74 && wind <= 95)
- disp("Category 1 storm, with a minimum surge of 4.")
- elseif (wind >= 96 && wind <= 110)
- disp("Category 2 storm, with a minimum surge of 6.")
- elseif (wind >= 111 && wind <= 130)
- disp("Category 3 storm, with a minimum surge of 9.")
- elseif (wind >= 131 && wind <= 154)
- disp("Category 4 storm, with a minimum surge of 13.")
- elseif (wind >= 155)
- disp("Category 5 storm, with a minimum surge of 18.")
- else
- disp("This storm is not large enough to have a category.")
- end
- %%
- %question 5
- %"Your friend who smokes cigarettes wants to know the total amount of
- %people he's made frown over time. Since he makes about 5 people a day
- %frown, write a loop that will add up that number of people for a given
- %amount of days."
- smonk = input("How many days do you want to calculate total frowns for? ");
- sum = 0;
- for i = 0:1:smonk
- sum = sum + 5;
- end
- fprintf("Your friend has made around %d people frown over time. Wow!", sum);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement