Question for Pascal users?

1 view (last 30 days)
Juan
Juan on 16 Mar 2018
Edited: Juan on 16 Mar 2018
I have a job application in which I need to solve an easy problem through programing. I've solved it through Matlab (my favourite software for these kind of problems) but they asked me to write it for Pascal software. I've never used that program and I'm stuck.
If someone knows Pascal language could you please translate the following code? It's really easy and short.
I thank you in advance
function [CT] = CostoTotal(U)
F(1)=0;
CE =0;
for dia=1:365
for hora=1:24
if hora<=7 & hora>=23
precio_horario=60*rand;
else
precio_horario=120*rand;
end
if precio_horario >= U
P=0;
else
P=1;
end
F(hora + (dia-1)*24 + 1)= F(hora + (dia-1)*24) + 1-P*5;
CE=CE + precio_horario*P;
end
end
cpp = sumsqr(max(F,0))*1000/8760;
CT = CE + cpp;

Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!