How do I prompt a user for their name and age, then display a sentence
41 次查看(过去 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!