Too many input argument?
5 ビュー (過去 30 日間)
古いコメントを表示
I am not sure what MATLAB means when there are too many input arguments. Specifically for this program, it says there is an error on line 21. I put asterisks on that line.
Response = 'Yes';
while (Response == 'Yes');
clc %This will clear the entire Command Window
clear %This will clear the all the values saved in the variables found in the Workspace
Decision = input('Would you prefer to input your own integers instead of randomly generated integers? Yes or No: ','s');
if 'Yes' == Decision
for Count = 1:1:10
FirstInteger = input('Enter an integer: ');
NearFirstInteger = round(FirstInteger);
SecondInteger = input('Enter another integer: ');
NearSecondInteger = round(SecondInteger);
* UserProduct = input('\nThe product of %.0f and %.0f is\n', NearFirstInteger, NearSecondInteger___);*
Product = NearFirstInteger*NearSecondInteger;
if UserProduct == Product
fprintf('You are correct!')
NumberCorrect = NumberCorrect + 1;
else
fprintf('You are incorrect. The correct answer is %.0f', Product)
end
end
else
for Count = 1:1:10
IntegerLimit = input('Enter the limit of the random integer: ')
firstinteger = round(rand(1)*IntegerLimit)
secondinteger = round(rand(1)*IntegerLimit)
userproduct = input('\nThe product of %.0f and %.0f is\n', firstinteger, secondinteger)
product = firstinteger*secondinteger;
if userproduct == product
fprintf('You are correct!')
NumberCorrect = NumberCorrect + 1;
else
fprint('You are incorrect. The correct answer is %.0f', product)
end
end
end
Grade = (NumberCorrect/10)*100;
if Grade <=100 & Grade >=90;
fprintf('You got a %.0f, an A', Grade)
elseif Grade <90 & Grade >=80;
fprintf('You got a %.0f, a B', Grade)
elseif Grade <80 & Grade >=70;
fprintf('You got a %.0f, a C', Grade)
elseif Grade <70 & Grade >=60;
fprintf('You got a %.0f, a D', Grade)
else
fprintf('You got a %.0f, a F', Grade)
end
Response = input('\nDo you wish to continue, Yes or No\n: ','s');
if Response == 'No'
fprintf = input('Thank you for the playing the MathGame');
end
end
0 件のコメント
回答 (1 件)
Walter Roberson
2013 年 3 月 15 日
Change
UserProduct = input('\nThe product of %.0f and %.0f is\n', NearFirstInteger, NearSecondInteger___);
to
UserProduct = input( sprintf('\nThe product of %.0f and %.0f is\n', NearFirstInteger, NearSecondInteger) );
and likewise for the case where the user enters their own integers.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Linear Least Squares についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!