:[ HOME ]:.  .:[ MY UNIVERSITY ]:.  .:[ KOS 1110 ]:.  .:[ MY ASSIGNMENTS ]:.  .:[ ISLAM & SCIENCE ]:.  .:[ TAZKIRAH ]:. .:[ MY FAMILY ]:.  .:[ MY FRIENDS ]:.  .:[CREDITS ]:.

 

KOS 1110 Computers in Science

Assignment 6–  Maple programming and Maplets

Due date Monday, 27-9-2004, 5pm

 

 

1) Write a Maple procedure (proc) called function(x), which will accept the variable a and x to calculate a function which has a value of 2*x^2+x+a in the range of -a to a, and a value of zero everywhere else.  Check your procedure by calling this proc using different values of x and a.

>

> restart;

f:=proc(a,x)

local z:

if x >=-8 and x<=8 then

 

z:=2*x^2+x+a:

else z:=0

fi:

end:

>

 

Example :

 

> f(-37,89);

 

 

> f(-3,7);

 

 

2) Write a Maple procedure (proc) called Grade(marks), which will accept a student's exam mark and returns his grade.

 

> restart;

> f:=proc(x)

> if x > 85

> then x = "A"         

>

> elif x > 80

> then x = "A-"

>

> elif x > 75

> then x = "B+"

>

> elif x > 70

> then x = "B"

 

 

> elif x > 65

> then x = "B-"

>

> elif x > 60

> then x = "C"

>

> elif x > 55

> then x = "C-"

>

> elif x > 50

> then x = "D"

>

> elif x < 50

> then x = "FAIL"

>

> fi:

> end;

       

Examples :

>

> f(82);

> f(58);

 

 

 

3.       Write the commands necessary to produce the following maplets:

 

a) Grader maplet which will accept a student's exam mark and returns his grade.

 

Include necessary titles, comments and buttons in all the above maplets.

 

> with(Maplets[Elements]):

>

> GradeMaplet:=Maplet ([[" GRADING EVALUATION "],

 

[" Enter the mark to be evaluated : ", TextField ['TF1']()],

 

TextBox['TB1'](not editable, width='40', height='3'), 

 

[Button ( "Get Grade", Evaluate ('TB1' = 'f(TF1)')),

 

Button ( " Finish ", Shutdown (['TF1', 'TB1']))]]):

 

Maplets[Display](GradeMaplet);

>

 

 

 

 

 

 

 

 

 

 

 

 

c) 3Dplotter maplet which accept any equation in two variables and draw a 3D plot.

 

> restart;

> with(Maplets[Elements]):

>

> PlottingMaplet:=Maplet(Window ('title' = " 3-D PLOTTER ", 'layout'='BL1'),

 

BoxLayout['BL1'](

 

BoxColumn(

 

BoxRow("Enter a function of 'x' to be plotted :"),

 

BoxRow(TextField['TF1']()),

 

BoxRow("Plot the function"),

 

BoxRow(Plotter['PL1']()),

 

BoxRow(Button("Get Graph", Evaluate('PL1'='plot3d(TF1, x=-10..10, y=-10..10)')),

 

Button("Finish",Shutdown(['TF1'])))

))):

 

Maplets[Display](PlottingMaplet);