필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Can't seem to get the values right. help?

조회 수: 1 (최근 30일)
Youssef Shams EL-Deen
Youssef Shams EL-Deen 2020년 8월 17일
마감: MATLAB Answer Bot 2021년 8월 20일
I can't seem to get the right answers for this question. I can't figure out what is wrong with my code.Keep in mind that fairly new to any programming so have patience with me plz and explaing in boring detail

답변 (1개)

SAA
SAA 2020년 8월 17일
The wait time and distance count as a whole and since they don't wanna round down ( they don't wanna even give a free centimeter ) as they suggest you shoud use ceil and the code should be like this:
function a = taxi_fare(d, t);
first_km_cost = 5;
additional_km = 2;
time_cost = 0.25;
%% this is what you are missing
d = ceil(d); % ceil rounds any number to the nearest integer greater than or equal to that number
t = ceil(t);
%% rest
x = d-1; y = t;
a = first_km_cost + (x*additional_km) + (y*time_cost) % you don't need the parentheses but I kept them since you had it
end

이 질문은 마감되었습니다.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by