Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1.Write a script file to permit a user to input their first name, last name, and

ID: 2995109 • Letter: 1

Question


1.Write a script file to permit a user to input their first name, last name, and date of birth as separate input values. Your script file will concatenate these values and print them to the screen on one line.










2. Grades are to be assigned as follows:

A 80% - 100%

B 65% - 79%

C 50% - 64%.

A. Write a script file to prompt the user to input a mark and display the appropriate grade. If the user enters a number greater than 100 or less than zero, display a message that the mark is invalid.


B. You are to make BOTH a IF/ELSEIF/END conditional version of your solution AND a second version using SWITCH statements.









3. In the space below, write a simple âfor loopâ to compute the factorial of the numbers 1 to 10. Test your process. Record your results in the space below as well. Do NOT use the âfactorial commandâ.





Explanation / Answer

clear;

clc;

first_name=input('enter the first name: ','s');

last_name=input('enter the last name: ','s');

dob=input('enter the date of birth(dd-mm-yyyy):','s');


output=cat(2,first_name, ' ', last_name, ',' , dob);




%part 2A----------------------------------------

clear;


disp('this is using if-else');

grade=input('enter the total marks: ');

if(grade>100)||(grade<0)

disp(' the marks entered is invalid');


elseif(grade<100)&&(grade>80)

disp(' the grade is A ');

elseif(grade<80)&&(grade>65)

disp(' the grade is B ');

elseif(grade<65)&&(grade>50)

disp(' the grade is C ');

end


%part 2B----------------------------------------

clear;


disp('this is using switch');

grade=input('enter the total marks: ');

switch grade>100 && grade <0

case 1

disp(' the marks entered is invalid');

case 0

switch grade>80 && grade <100

case 1

disp(' the grade is A ');

case 0

switch grade>65 && grade <80

case 1

disp(' the grade is B ');

case 0

disp(' the grade is C ');

end

end

end


%part 3 -----------------------------------------


clear;

disp('this is the third part');

num=1:10;

fact=1;

for i=1:size(num,2)

fact=fact*num(i);

end

x=sprintf('the factorial is %i',fact);

disp(x);




Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote