无限的循环,不会减去数字

时间:2016-03-31 03:09:37

标签: matlab loops while-loop

我试图计算米达到35米以下所需的烧伤次数。我在使用while循环时遇到了麻烦。这是无限的,我试图保持减法,直到它小于35米,但它不会减去任何东西。

% Inputs
burns = input('Enter the distance to be traveled in kilometers: ');
meters = burns*1000;
count = 0;
left = meters;

 % While loop
while  left >= 35;
    count = count+1;
    travel = meters*0.6;
    left = meters-travel;
    fprintf('Burns: Traveled %.2f meters\n \t\t %.2f meters left\n',travel,left);
end
fprintf('You made it to Jupiter in %d burns\n',count);

0 个答案:

没有答案