Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Your friend Maverick recently landed a lucrative engineering co-op work term in an oil rich country. Meanwhile, you chose to make a modest salary as

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Your friend Maverick recently landed a lucrative engineering co-op work term in an oil rich country. Meanwhile, you chose to make a modest salary as a co-op inten with the Canadian Security Intelligence Service (CSIS). A week after arriving in the foreign country, Maverick is kidnapped by rebels opposed to oil exploration. He is held captive in a small village within rebel territory. Luckily, a group of disenchanted rebels are willing to smuggle Maverick to one of seven rendezvous points: the village bridge the village library - -river crossing nearby airport -bus terminal hospital -at St. Pete's Church where an allied helicopter will pick them up and fly them to safety. For the plan to work the friendly rebels need to know two pieces of information: - the day of the rendezvous -the rendezvous point CSIS has devised a nine-digit code the time is ripe, CSIS will insert a coded message into the online newspaper of the oil- rich country, as a number on the front page. The rebels have Internet access via satellite links and follow the news. While it is helpful (as a decoy strategy) that the newspaper has other numbers on the front page, e.g. in real adverts, it is vital that the rebel insiders can detect and decode the secret message. CSIS has found a way to smuggle a decoder to the friendly rebels. You are asked to program the decoder in MATLAB. The safety of your friend Maverick depends on your ability to program the decoder comectly to carry this information to the friendly rebels. Wher Details The four rules for detecting and decoding the code are as follows: 1.A valid code must be a 9-digit number e.g. 123456789, message MAY be valid e.g. 12345678, message invalid e.g. 1234567890, message i invalid Assume that the input data contains only digits, with a non-zero first digit. Output Your output should look like the example screenshots below. Here are 3 valid messages: di Command Window Please enter a code to break: 111600542 Rescue on Monday at the river crossing Command Window Please enter a code to break: 364686902 Rescue on Thursday at St. Petes Church. Command Window Please enter a code to break: 332837840 Rescue on Wednesday at the airport. Your output for invalid messages should indicate only the first reason encountered for rejecting the message. The reasons are one of the following, in this order Decoy Message: Not a nine-digit number. Decoy Message: Sum is odd. -Decoy Message: Invalid rescue day. Decoy Message: Invalid rendezvous point Command Window Please enter a code to break: 1234567 Decoy message: Not a nine-digit number. .Command Window Please enter a code to break: 364686910 Decoy message: Sum is odd. Command Window Please enter a code to break: 362182666 Decoy message: Invalid rescue day. Command Window Please enter a code to break: 364686911 Decoy message: Invalid rendezvous point You are required to use two switch statements in this assignment, one to determine the reseue day and another to detemine the rendezvous point. Failure to use two swilch statements in this assignment will result in a mark of zero on Successful testing of the rules portion of the mark breakdown Hints 1. Before you even begin to write out any MATLAB code, sit down and sketch out your program design in abbreviated English. This kind of high-level program design is called pscudo code. Please see secondary link for full pseudo code of the assignment two. It would start off something like this: Get secret code from nser as a string Get an amay of the individual digits fcode not 9 digits Omput error message Else Get sum of digits f sum is odd Output error message Else Get rescue day Notice how the logic naturally translates into an if-else chain. The if clauses in the chain contain messages for invalid codes. After such a message is output, the control flow breaks out of the entire chain. You end up reaching the final else clause in the chain only if the code is valid. It is there that the valid message is composed and output. 2. To help you read in a secret code from the user as a string, type in help input on the command window or search the input command using the help function 3. When converting an array of characters (string) to an aray of numbers, you noed to subtract the ASCIl value of zero from each character. For example, if your string is called code str and your number array is called digits, you can do the following digits-code str- ENCMP 100-Computer Programming for Engineers Page 7 of 7 4. Remember to use the built-in MATLAB functions, For example, to check if the string contains nine digits, you might find the length function helpful. To find the sum of the digits, you might find the sum fanction helpful. To check if the sum of digits is odd or even, you may find the mod function helpful. 5. Build up your program design in stages. After you have completed the code for Rule 1, compile and lest with a varicty of codes that satisfy and fail to satisfy the rule. Then go on to wite the code for the next rule, ete. 6. Please remember to include your header at the top of your m file

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

Transactions On Large Scale Data And Knowledge Centered Systems X Special Issue On Database And Expert Systems Applications Lncs 8220

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Stephen W. Liddle ,Klaus-Dieter Schewe ,Xiaofang Zhou

2013th Edition

ISBN: 3642412203, 978-3642412202

More Books

Students also viewed these Databases questions