Practice Questions You are not required to submit solutions screensho.docx

This preview shows page 1 - 3 out of 3 pages.

Image of page 1

Subscribe to view the full document.

Practice Questions You are not required to submit solutions screenshots of practice questions. You have to submit the solution and screenshot for only the homework question given after the practice questions. Practice Question 1. For a given message and a key, write a program to repeat the characters of a key in the form of the message. Assume that the length of the key is less than or equal to the message and all the letter in the key are in lowercase. Program Inputs Enter the message: The user will always enter a string! Enter the key: - The user will always enter a string! Program Outputs The new string is: XXX - Replace XXX with the output! Sample Output Test Case 1: Enter the message: helloWORLD Enter the key: matlab The new string is: matlaBMATL Test Case 2: Enter the message: strings are vectors Enter the key: woot The new string is: wootwoo two
Image of page 2
Image of page 3

Unformatted text preview: otwootw Test Case 3: Enter the message: Kosm urm lhrrfdr uzwcxb! Enter the key: rusty The new string is: Rust yru styrust yrusty! %HW 9 Practice Question clc; clear; message=input('Enter the message: ','S'); key=input('Enter the key: ','S'); count=1; for ii=1:1:length (message) let-message (ii); storing the � message count=count+1; if isletter (let) fif the message is a letter, then the message is switched to the key let=key (ii); if find(isstrprop (message (ii), 'upper')) %if a letter is uppercase, you switch the key to uppercase too let=upper (key(ii)); if count>length (key) count=1; end end end message (ii)=let; end fprintf('The new string is %s', message); mand Window nter the message: helloWORLD nter the key: matlab ndex exceeds the number of array elements (6). rror in Untitled? (line 12) let=key (ii);...
View Full Document

  • Fall '19

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes