MATLAB Answers

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Asking a user to solve a riddle

조회 수: 1(최근 30일)
Breanna Sokolik
Breanna Sokolik 2020년 10월 23일
마감: Rik 2020년 10월 24일
riddle1prompt='The person who built it sold it. The person who bought it never used it. The person who used it never saw it. What is it? ';
riddle1=input(riddle1prompt,'s');
riddle1='Coffin';
fprintf('\n')
if (riddle1=='Coffin')
riddle2prompt='Nice job. Your next riddle is; I dont have eyes, but once I did see. Once I had thoughts, but now Im white and empty. What am I? ';
riddle2=input(riddle2prompt,'s');
riddle2='Skull';
elseif(riddle1~='Coffin')
fprintf('Oh no, what did I say about not messing up. ITS GAME OVER FOR YOU,%s.',name)
firstroom=false;
end
if (riddle2=='Skull')
riddle3prompt='He comes to bedsides, icy bridges, battlefronts, and crumbling ridges. When he comes, he comes alone, taps a shoulder, then is gone. What is he? ';
riddle3=input(riddle3prompt,'s');
riddle3='Death';
elseif(riddle2~='Skull')
fprintf('Oh no, what did I say about not messing up. ITS GAME OVER FOR YOU,%s.',name)
firstroom=false;
I am having issues getting the elseifs to work in the code, what am I doing wrong with the inputs?

답변(0개)

제품


릴리스

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by