Question

asks the user for a word in the form of a string using matlab asks the...

asks the user for a word in the form of a string using matlab

asks the user for a letter

check to see if the letter is contained in the word

if the letter is not contained, prints out sorry

if the letter is contained print out the word

Homework Answers

Answer #1

%matlab code

word = input('Enter a word: ', 's');
letter = input('Enter a letter: ', 's');

flag = 0;
% put flag 1 is letter is found in word
for i=1:length(word)
    if word(i) == letter
        flag = 1;
    end
end

% print according to the value of word
if flag == 1
    disp(word);
else
    disp('Sorry!');
end

%{
output:

Enter a word: ayush
Enter a letter: v
Sorry!

%}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
write a program that asks the User to enter a letter, then asks the user to...
write a program that asks the User to enter a letter, then asks the user to enter a sentence. the program will then print out how many time that letter occurred in the sentence. in C Language
Write a program using Matlab that asks the user for their last three grades and final...
Write a program using Matlab that asks the user for their last three grades and final grade and gives them their overall final grade. The three Midterms are worth 70% and Final is worth 30%. The program will display their Final grade with a grade letter corresponding to it. Run your program and verify that it operates correctly (hint: you might need to use “If, else statements”)
Prompt the user for a text string. Print each letter of the string to the console...
Prompt the user for a text string. Print each letter of the string to the console in reverse order. When finished print “I’m done” on a new line. Do not use any looping constructs to accomplish this. This means no DO, While or For loops In Java For example, if the user were to input “Hello”. The out put would be : olleH I’m done.
1)Write a program that asks a user for a number. If (and only if) the number...
1)Write a program that asks a user for a number. If (and only if) the number is greater than zero print “The number is valid” 2)Write a program that asks a user for a grade. If (and only if) the grade is greater than zero and less than 101, print “The grade is valid” 3)Write a program that asks a user how many widgets they want to buy and prints out what the user should pay. Widgets costs 10 dollars....
Write a MATLAB while-loop code that asks a user to enter an integer number until its...
Write a MATLAB while-loop code that asks a user to enter an integer number until its factorial is smaller than 100.
Using C++ 1. Create a program that asks the user to create 5 triangles, asking for...
Using C++ 1. Create a program that asks the user to create 5 triangles, asking for 5 bases and 5 heights (you can use an array), have a function to print the triangle bases, heights, and areas 2. Create a structure for the Triangle that holds the base and height of the triangles. Ask the user for 5 triangles, and print them. 3. Create an array of 5 structures - ask the user for 5 triangles, and then print the...
in c++ Write a C++ program that asks the user to enter an integer number and...
in c++ Write a C++ program that asks the user to enter an integer number and prints it back "vertically" to the screen. Use recursion in your solution. As an example of how the program will work: Please enter an integer: 12345 The integer you entered will print vertically as: 1 2 3 4 5
draw flowchart of: 1-algorithm that asks the user to enter three numbers and computes and prints...
draw flowchart of: 1-algorithm that asks the user to enter three numbers and computes and prints out the largest number. 2- an algorithm that asks the for an integer N from the user. The algorithm should find whether the number is positive, negative, or ZERO. 3-an algorithm that asks the user to enter a positive integer N. You then need to calculate the sum of all values from 1 to N.
A. Write a Java program that asks the user to enter “bus” or “subway” or “walk”....
A. Write a Java program that asks the user to enter “bus” or “subway” or “walk”. If the user enters “bus” display “$1.00”. If they enter “subway” display “$1.50 and if they enter “walk” display “Free”. B. Write a java program that creates the following two arrays: String[] candidates = {“S Jones”,”Justin Fairfax”,”Clark Duncan”}; int[] votes = {7345,4324,3211}; Write the code that will search the votes array for the candidate with the largest number of votes and prints the name...
COBOL Translate English to Pig Latin This interactive program translates any word the user enters into...
COBOL Translate English to Pig Latin This interactive program translates any word the user enters into Pig Latin. The interactive session --------------------------------------------- Enter any word to see what it looks like in Pig Latin. To quit, type Uitqay. --------------------------------------------- string The Pig Latin equivalent is: Ingstray --------------------------------------------- unstring The Pig Latin equivalent is: Unstringlay --------------------------------------------- Uitqay Oodbyegay! Specifications • If the word starts with a consonant, move the consonants before the first vowel to the end of the word and...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT