CS Answer for programming page.66
Q6
program page66q6; uses wincrt;
var L1, L2, L3 : real;
begin
write('Enter lengths of 3 sides: ');
readln(L1, L2, L3);
if (L3>L1) and (L3>L2)
then begin
if sqrt(L1*L1+L2*L2)=sqrt(L3*L3)
then writeln('They form a right-angled triangle.')
else writeln('They do not form a right-angled triangle.')
end
else writeln('Please type the lengths in increasing order.')
end.
|
Q7
program page66q7; uses wincrt;
var score1, score2 :integer;
average : real;
grade : string;
begin
write('Enter test and exam score: ');
readln(score1, score2);
average := score1*40/100+score2*60/100;
case trunc(average) of
90..100 : grade := 'A';
80..89 : grade := 'B';
70..79 : grade := 'C';
60..69 : grade := 'D';
0..60 : grade := 'E'
end;
writeln('Average = ',average:0:1,' Grade = ',grade)
end.
|
Q8
program page66q8; uses wincrt;
var Name : string;
Income, NChild, NParent : integer;
ChargeIncome, Tax, TotalAllow : real;
MStatus : char;
begin
write('Name? ');
readln(Name);
write('Total annual income? ');
readln(Income);
write('Marital status (M = married, S = single)? ');
readln(MStatus);
write('Number of children? ');
readln(NChild);
write('Number of dependent parents? ');
readln(NParent);
if NChild > 5
then NChild := 5;
if NParent > 4
then NParent := 4;
case MStatus of
'M' : TotalAllow := 30000+30000+NChild*10000+NParent*15000;
'S' : TotalAllow := 30000+NChild*10000+NParent*15000
end;
ChargeIncome := Income-TotalAllow;
if ChargeIncome <= 20000
then Tax := ChargeIncome*10/100;
if (ChargeIncome > 20000) and (ChargeIncome <= 40000)
then Tax := 20000*10/100+(ChargeIncome-20000)*20/100;
if ChargeIncome > 40000
then Tax := 20000*(10/100+20/100)+(ChargeIncome-40000)*30/100;
if Tax > ChargeIncome*25/100
then Tax := ChargeIncome*25/100;
writeln('Tax for ',Name,' is ',round(Tax))
end.
|
¡@