(*Exercise 02*)
ClearAll[tt,sol1]
(*Input Part*)
tt=Table[i,{i,1998,2025}];
pp={48,50,55,55,59,69,82,91,102,110,115,120,125,133,145,159,150,177,117,117,142,133,137,157,303,355,355,309};
(*Calculation Part*)
(*Part i*)
ttpp=Transpose[{tt,pp}];
gttpp=ListPlot[ttpp,PlotStyle->Red,AxesLabel->{"Time(year)","Petrol Prices (Rs)"},PlotLabel->"Petrol Prices (Rs) vs Time"];
(*Part ii*)
fttpp=Fit[ttpp,{t^3,t^2,t,1},t];
gfttpp=Plot[fttpp,{t,tt[[1]],Last[tt]},PlotStyle->Green];
(*Part iii*)
sol=fttpp/.t->{2026,2027,2028,2029,2030};
(*Part iv*)
sol1=fttpp/.t->2050;
(*Output Part*)
Print[Style["Exercise 2-part (i)",Bold]]
gttpp
Print[Style["Exercise 2-part (ii)",Bold]]
Print["Suitable Model is ",fttpp]
Show[{gttpp,gfttpp}]
Print[Style["Exercise 2-part (iii)",Bold]]
Print["Average Petrol Prices in 2026, 2027, 2028, 2029, and 2030 are ",sol[[1]],", ",sol[[2]],", ",sol[[3]],", ",sol[[4]],","," and ",sol[[5]]," respectively."]
Print[Style["Exercise 2-part (iv)",Bold]]
Print["Average Petrol Prices in 2050 is ",sol1]