Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribedUsing 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 program

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

XML Data Management Native XML And XML Enabled Database Systems

Authors: Akmal Chaudhri, Awais Rashid, Roberto Zicari, John Fuller

1st Edition

0201844524, 978-0201844528

More Books

Students also viewed these Databases questions