Two cars A and B are travelling the same direction The cars
Solution
intial velocity u = 65mph=95.3 ft/s
I did everything in code.
u = 95.3;% initial velocity
 a1 = 10/3; % decceleration of car A, considered g=10
 a2 = 20/3;
 t = 0:0.01:6 % in seconds
 t1 = u/a1; % Time for car A to stop
 t2 = u/a2+2; %Time for car B to stop
 %Both cars have same veloity at t = 0 and t1=28.6s and t2 = 14.3s
 %Plot of Velocity of both the cars
 v1 = u*t-a1*t;
 v2 = u*(t)-a2*(t-2);
 plot(t,v1);
 hold on
 plot(t,v2);
 hold off
%Plot of Distance travelled
 s1 = u*t-a1*t.^2/2; % Distance travelled by the car A
 s2 = u*(t)-a2*(t-2).^2/2; % Distance travelled by the car B
 plot(t,s1,\'r\');
 hold on
 plot(t,s2);
 hold off
 s = s1-s2;
plot(t,s); % Diffreence of distance with time
 % in time t car A will move s1 distance And car B moves s2= u(t)-a2*(t-2)^2
 % Distance need to avoid collision is s = s1-s2
 d = (a1*t^2+a2*(t-2)^2)/2;
 % so time at which it will collide is
 T = (2*sqrt(a2)/(sqrt(a1)-sqrt(a2));
 
 D = a2*2.5^2+a2*.5^2;
 V = u*t-a1*t-v2 = u*2.5-a2*.5 % Differential speed

