How do I prompt a user for their name and age, then display a sentence
조회 수: 57 (최근 30일)
이전 댓글 표시
I am so lost on this and I know it’s very simple I want to prompt a user for their name and their age. I then want to take their age and add a number, 5. Then I wold like to display a sentence that says “hello (name) in 5 years you will be (age+5)
댓글 수: 0
답변 (2개)
Image Analyst
2020년 9월 16일
Hint: Use input() and fprintf():
userResponse = input(...........................
fprintf('Hello %s in ......................\n', variable1, variable2);
See if you can finish it.
Samiu Haque
2020년 9월 16일
Maybe this is what you want-
name = input('Enter your name: ','s');
age = input('Enter your age: ');
fprintf('Hello %s in 5 years you will be %d\n',name,age+5)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!