Response = 'Yes';
while (Response == 'Yes');
clc
clear
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