# Trying to create a script which returns a t-value corresponding to a y-value input by the user, however calculations aren't being performed correctly/ not returning the right values.

조회 수: 5(최근 30일)
Jhin Michael 6 Apr 2020
댓글: Rena Berman 14 May 2020 16:05
close all
clear all
prompt = 'What is the value of y : ';
y = input(prompt)
if y<10000
t = 200;
elseif 10000 <= y <= 20000
t = 200+0.1*(y-10000);
elseif 20000 <= y <= 50000
t = 1200+0.15*(y-20000);
elseif y>50000
t = 5700+0.25*(y-50000);
end
disp('The corresponding value of t is:')
disp(t)
Calculations being done by the last two "elseif" statements aren't correct. I'm not receiving any errors so I'm unsure what I'm doing incorrectly.

#### 댓글 수: 2

Stephen Cobeldick 7 Apr 2020
Original question by Jhin Michael, copied from Google Cache:
"Trying to create a script which returns a t-value corresponding to a y-value input by the user, however calculations aren't being performed correctly/ not returning the right values."
close all
clear all
prompt = 'What is the value of y : ';
y = input(prompt)
if y<10000
t = 200;
elseif 10000 <= y <= 20000
t = 200+0.1*(y-10000);
elseif 20000 <= y <= 50000
t = 1200+0.15*(y-20000);
elseif y>50000
t = 5700+0.25*(y-50000);
end
disp('The corresponding value of t is:')
disp(t)
Calculations being done by the last two "elseif" statements aren't correct. I'm not receiving any errors so I'm unsure what I'm doing incorrectly.
Rena Berman 14 May 2020 16:05

로그인 to comment.

### 답변(1개)

darova 6 Apr 2020
See the solution #### 댓글 수: 0

로그인 to comment.

이 질문에 답변하려면 로그인을(를) 수행하십시오.

R2019b