Rupunzel

15 Reputation

3 Badges

11 years, 217 days

MaplePrimes Activity


These are questions asked by Rupunzel

I've tried all sorts of different assignments for a,b and c but all still give me an error 
for root 2. 
have tried posint, int, nonnegative, positve but none work 
any help would be appreciated. 
 
isTriangle:=proc(a::posint,b::posint,c::posint)
if (a+b) > c then print (a,b,c,`are lengths of a triangle`)
#this is according to the triangle inequality theorem
elif (a+b) < c then print ...

I've tweaked it a bit to now look like this. Trialed it out with some examples:

Marks:=proc(m::positive)
if m < 40 then print (m, `Fail`)
elif m < 50 then print (m, `Third Class`)
elif m < 60 then print (m, `Lower Second Class`)
elif m < 70 then print (m, `Upper Second Class`)
elif m < 100 then print (m, `First Class`)
elif m > 100 then print (`error`)
else end if;
end proc;
proc(m::positive) ... end;
Marks(30);

Q3) Write a procedure, isTriangle, to determine if any three given
 numbers represent the lengths of the sides of a triangle.
The procedure should be able to deal with any input.

I have done the following and get an error
 

isTriangle:=proc(a,b,c::nonnegative and numeric)
if (a^2+b^2)=c^2 then print (a,b,c "represent the sides of a triangle")
end if;
end proc;
Error, unexpected string

Thanks very much for your help!
So I've done this so far:
 
Marks:=proc(m::nonnegative, numeric)
if m < 40 then print (m, Fail)
elif m < 50 then print (m, `Third Class`)
elif m < 60 then print (m, `Lower Second Class`)
elif m < 70 then print (m, `Upper Second Class`)
elif m < 100 then print (m, `First Class`)
elif m > 100 then print (`error`)
end if;
end proc;
proc(m::nonnegative, numeric) ... end;
Been attempting this question for some time now and can't seem to get it right. 
Each time coming up with a different error.
It's part of our weekly homework, an extention question.
 
Write a procedure, marks, to take a student’s mark and output the appropriate grade, 
based on the following table:

mark 0-39.99 40-49.99 50-59.99 60-69.99 70+
Page 1 of 1