Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Using Matlab Coding Please Write a small program to simulate a submarine shooting torpedoes; the program has the functions main, fc_input, shoot_torpedoes, performing the following
Using Matlab Coding Please
Write a small program to simulate a submarine shooting torpedoes; the program has the functions main, fc_input, shoot_torpedoes, performing the following steps: Function main calls the function fc_input. Function fc_input asks for user to type how much torpedoes are loaded and if we have hurricanes today {1: for yes; 0: for no}; then fc_input returns the weather condition for hurricanes and the number of torpedoes to the function main as the information was provided by the user through the keyboard. Function main calls the function shoot_torpedoes, sending the torpedoes and hurricanes information to function shoot_torpedoes; Inside the function shoot_torpedoes, if we have hurricanes don't go shooting torpedoes and print the message "Hurricanes expected - not sailing today" and in such case end the program; otherwise, keep shooting torpedoes until there is no torpedoes left; every loop subtract 1 torpedo from the ammunition (torpedoes), printing the message e.g.: "shooting torpedo... now left torpedoes = 5" showing the value of the variable torpedoes; when torpedoes get equal to 0 (zero) print the message "not shooting for now, torpedoes left = 0" showing the value of the variable torpedoes, then finish the programStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started