clear all 
format long
%%
prompt = {'Input age of the person'};
title = 'Age';
opts.Interpreter = 'tex';
age = str2num(cell2mat(inputdlg(prompt,title,[1 40])))
%%
answer = questdlg('Does the person have a criminal record?', ...
	'Criminal record', ...
	'No or not related','One offece stadium or violence related','Stadium or violence recidivism', 'cos');
% Handle response
switch answer
    case 'No or not related'
        disp([answer 'No or not related'])
        record = 0;
    case 'One offece stadium or violence related'
        disp([answer 'One offece stadium or violence related'])
        record = 1;
    case 'Stadium or violence recidivism'
        disp([answer 'Stadium or violence recidivism'])
        record = 2;
end
%% 
answer = questdlg('Does the person belong to the suppoter association?', ...
	'If member of association', ...
	'Yes','No','cos');
% Handle response
switch answer
    case 'Yes'
        %disp([answer 'No or not related'])
        member = 1;
    case 'No'
        %disp([answer 'One offece stadium or violence related'])
        member = 0;
end
%%
answer = questdlg('What sector is it?', ...
	'Sector', ...
	'Supporters','Regular','cos');
% Handle response
switch answer
    case 'Supporters'
        %disp([answer 'No or not related'])
        sector = 1;
    case 'Regular'
        %disp([answer 'One offece stadium or violence related'])
        sector = 0;
end
%% sector points 
points = 0 ;
if sector == 1  %supporters 
  points = points +50;
    if age >= 50
        points = points + 0 ;
    elseif (age>= 21) && (age< 50)
        points = points + 10 ;
    elseif  (age>=14) && (age<21)
        points = points + 5 ;
    else
        points = points - 5 ;
    end
else
  points = points +35;
    if age >= 50
        points = points + 0 ;
    elseif (age>= 21) && (age< 50)
        points = points + 10 ;
    elseif  (age>=14) && (age<21)
        points = points + 5 ;
    else
        points = points - 5 ;
    end    
end
%% club supporter points 
if member == 1
    points = points +5 ;
else 
    points = points;
end
%% criminal record 
if sector == 1  %supporters 
    if record == 0;
        points = points + 0 ;
    elseif record == 1;
        points = points + 26 ;
    else
        points = points + 35;
    end
else
    if record == 0;
        points = points + 0 ;
    elseif record == 1;
        points = points + 40 ;
    else
        points = points + 50;
    end
end
%%
message = sprintf('Calculated points %d', points);
msgbox(message)
%% 
answer = questdlg('How bussy it is?', ...
	'Crowd flow', ...
	'Big flow','Normal Flow','Small Flow', 'cos');
% Handle response
switch answer
    case 'Big flow'
        %disp([answer 'No or not related'])
        flow = 3;
    case 'Normal Flow'
        %disp([answer 'One offece stadium or violence related'])
        flow = 2;
   case 'Small Flow'
        %disp([answer 'One offece stadium or violence related'])
        flow = 1;
end

%%
if flow == 1
    if points >= 85
        search = 100;
    elseif (points >75) && (points<85)
        search = 100;
    elseif (points<= 75) && (points>= 65)
        search = 50;
    elseif (points<65) && (points>= 50)
        search = 5;
    else
        search = 1;
    end
elseif flow == 2
    if points >= 85
        search = 100;
    elseif (points >75) && (points<85)
        search = 75;
    elseif (points<= 75) && (points>= 65)
        search = 25;
    elseif (points<65) && (points>= 50)
        search = 2;
    else
        search = 0.5;
    end
else 
    if points >= 85
        search = 100;
    elseif (points >75) && (points<85)
        search = 50;
    elseif (points<= 75) && (points>= 65)
        search = 15;
    elseif (points<65) && (points>= 50)
        search = 1;
    else
        search = 0.1;
    end
end
%%
message1 = sprintf('Calculated personal search probability (in procents) %d', search);
msgbox(message1)
%%

a = [ 0.23  0.77]

b= [ 0.27 0.05 .65 .03]

c= [5.6/100 0.944]

d= [ 0.0214/100 0.061/100 .999176 ] 

%biggest group 
out(1) = a(2) * b(3) *c(2) * d(3)
%% people with crimminal record 

crime(1) = a(1) * b(1)*  c(1) *d(1)
crime(2) = a(1) * b(2)*  c(1) *d(1)
crime(3) = a(1) * b(3)*  c(1) *d(1)
crime(4) = a(1) * b(1)*  c(2) *d(1)
crime(5) = a(1) * b(2)*  c(2) *d(1)
crime(6) = a(1) * b(3)*  c(2) *d(1)
crime(7) = a(1) * b(1)*  c(1) *d(2)
crime(8) = a(1) * b(2)*  c(1) *d(2)
crime(9) = a(1) * b(3)*  c(1) *d(2)
crime(10) = a(1) * b(1)*  c(2) *d(2)
crime(11) = a(1) * b(2)*  c(2) *d(2)
crime(12) = a(1) * b(3)*  c(2) *d(2)

crime(13) = a(2) * b(1)*  c(1) *d(1)
crime(14) = a(2) * b(2)*  c(1) *d(1)
crime(15) = a(2) * b(3)*  c(1) *d(1)
crime(16) = a(2) * b(1)*  c(2) *d(1)
crime(17) = a(2) * b(2)*  c(2) *d(1)
crime(18) = a(2) * b(3)*  c(2) *d(1)
crime(19) = a(2) * b(1)*  c(1) *d(2)
crime(20) = a(2) * b(2)*  c(1) *d(2)
crime(21) = a(2) * b(3)*  c(1) *d(2)
crime(22) = a(2) * b(1)*  c(2) *d(2)
crime(23) = a(2) * b(2)*  c(2) *d(2)
crime(24) = a(2) * b(3)*  c(2) *d(2)

sum (crime) *18000 *23
 
%% no crime 
nocrime(1) = a(1) * b(1)*  c(1) *d(3)
nocrime(2) = a(1) * b(2)*  c(1) *d(3)
nocrime(3) = a(1) * b(3)*  c(1) *d(3)
nocrime(4) = a(1) * b(4)*  c(1) *d(3)
nocrime(5) = a(1) * b(1)*  c(2) *d(3)
nocrime(6) = a(1) * b(2)*  c(2) *d(3)
nocrime(7) = a(1) * b(3)*  c(2) *d(3)
nocrime(8) = a(1) * b(4)*  c(2) *d(3)
nocrime(9) = a(1) * b(1)*  c(1) *d(3)
nocrime(10) = a(2) * b(2)*  c(1) *d(3)
nocrime(11) = a(2) * b(3)*  c(1) *d(3)
nocrime(12) = a(2) * b(4)*  c(1) *d(3)
nocrime(13) = a(2) * b(1)*  c(2) *d(3)
nocrime(14) = a(2) * b(2)*  c(2) *d(3)
nocrime(15) = a(2) * b(3)*  c(2) *d(3)
nocrime(16) = a(2) * b(4)*  c(2) *d(3)

sum (nocrime) *100
%% 
biggest_g = 0.23*0.65*0.056*0.999176 *18000