Problem #17 of the book: THE MAN WHO COUNTED (Sample Programs)

by lrcvs, Thursday, June 27, 2013, 18:36 (1399 days ago)
edited by lrcvs, Thursday, June 27, 2013, 19:19

Problem #17 of the book: THE MAN WHO COUNTED

Caption/title: THE APPLES AND ANTS or 90 APPLES

See:

http://www.arvindguptatoys.com/arvindgupta/count.pdf

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

cls
#apples
a0 = 50
b0 = 30
c0 = 10

m = 0
mk = 0
ml = 0
mj = 0
y = 0
for j = 1 to 10
x = 0
#grups of apples
a1 = int(a0/j)
b1 = int(b0/j)
c1 = int(c0/j)
#remain of apples
a2 = a0 - (a1*j)
b2 = b0 - (b1*j)
c2 = c0 - (c1*j)
#comprobate apples
a3 = a1 + a2
b3 = b1 + b2
c3 = c1 + c2

if (a1*j)+a2 = a0 and (b1*j)+b2 = b0 and (c1*j)+c2 = c0 then
x = 1
end if

if x = 1 then
for k = 1 to 10 #price first phase
for l = 1 to 10 #price second phase
a5 = (a1 * k) + (a2 * l)
b5 = (b1 * k) + (b2 * l)
c5 = (c1 * k) + (c2 * l)

if a5 = b5 and a5 = c5 and b5 = c5 then
print "fatima first phase : "+a1*j +" apples bring a profit of "+a1*k +" dinars"
print "fatima second phase: "+a2+" apples bring a profit of "+a2*l +" dinars"
print "fatima total : "+a0+" apples bring a profit of "+a5 +" dinars"
print
print "cunda first phase : "+b1*j +" apples bring a profit of "+b1*k +" dinars"
print "cunda second phase: "+b2+" apples bring a profit of "+b2*l +" dinars"
print "cunda total : "+b0+" apples bring a profit of "+b5 +" dinars"
print
print "shia first phase : "+c1*j +" apples bring a profit of "+c1*k +" dinars"
print "shia second phase: "+c2+" apples bring a profit of "+c2*l +" dinars"
print "shia total : "+c0+" apples bring a profit of "+c5 +" dinars"
print

goto fin
end if

next l

next k
end if

next j
fin:
print "End"

end


Complete thread:

 RSS Feed of thread

powered by my little forum