Write a MATLAB program to ask A for your first and last nam
Write a ((MATLAB)) program to ask :
A- for your first and last names and when you enter your names (at the same time), you deliberately misspell a letter in your last name when you enter them.
B- Program prints out your first and last name and asks for confirmation of your name correct spelling by asking you to enter 1 for correct and 0 for not correct.
C- After entering 0, the program asks you to enter a number and a string at the same time. The number is the index of the letter that is wrong in your name (count from zero) and letter is the correct letter.
D- After you enter these, the program print your first and last name with correct spelling.
Show the program entire output
Solution
Matlab Code:
clc;
clear all;
name = input(\'Enter your first name and last name with space between them:\ \',\'s\');
decision = input(\'Have you entered the correct input:\');
if decision == 0
indexletter = input(\'give the index and letter: \',\'s\');
[r c]=size(indexletter);
for i=1:c%loop to split using space
if indexletter(i)~=\' \'
index(i)=indexletter(i);
else
str = indexletter(i+1);
break;
end
end
index = str2double(index);
name(index+1)=str;
disp(name);
else
disp(name);
end
Enter your first name and last name with space between them:
Jai Javin
Have you entered the correct input:0
give the index and letter: 7 a
Jai Javan
