Vous êtes sur la page 1sur 15

SCHEME QUESTION BANK

1. Develop a function to return the mean of 5 exam scores.


(define mean
(lambda ( a b c d e)
(/ (+ a b c d e) 5)))

2. Develop a function that when given the area of a square will calculate its perimeter.
(define perimeter
(lambda (x)
(* (sqrt x) 4)))

3. Evaluate the following Expressions in Scheme :


(a) n^2 + 10
(b) (1/2) · n^2 + 20
(c) 2 - (1/n)
a)
(define expp
(lambda (n)
(+ 10 ( expt n 2))))
b) (define expp
(lambda (n)
(+ 20 (* ( expt n 2)( / 1 2)))))
c) (define expp
(lambda (n)
(- 2 (/ 1 n)))

4. Define the program triangle. It consumes the length of a triangle's side and the perpendicular
height. The program produces the area of the triangle.
( define area_tri
(lambda (l1 h)
(* (/ 1 2) l1 h)))

5. Sum and Average of n number.


(define(sum-of-n-number n)
(/(* (+ n 1) n) 2)
( define (average n)
(/ (* (+ n 1) n) 4))

6. Develop a function that computes the area of a regular polygon given the length of one side
and the number of sides. If n is the number of sides and s is the length of a side, the area of a
regular polygon is equal to 1/4 * n * s2 * 1/(tan PI/n).
(define area_poly
(lambda (s n)
(/ (* n (* s s)) (* 4 (tan(/ 3.14 n))))))

7. Develop a function that when given an initial amount of money (called the principal), a simple
annual interest rate, and a number of months will compute the balance at the end of that
time. Assume that no additional deposits or withdrawals are made and and that a month is
1/12 of a year. Total interest is the product of the principal, the annual interest rate expressed
as a decimal, and the number of years.
(define bal
(lambda (pr rate t_mnths)
(/ (* pr rate (/ t_mnths 12)) 100)))

8. Develop a function to calculate total tax liability for ANY given income. Assume that the share
of income $35,000 and below is federally taxed at 15%, the share of income between $35,000
and $100,000 is taxed at 25%, and the share of income over $100,000 is taxed at 35%.
Assume that there is no state income tax for income up to $50,000 but is a flat 5% for all
income above $50,000
(define (tax x)
(= x (- x 50000))
(cond
(< x 35000) (* 0.15 x)
(AND (> x 35000) (< x 100000)) (* 0.25 x)
(> x 100000) (* 0.35 x)
(else 0)
)
)

9. Develop a function that computes how long after their deparature two trains will meet.
Assume that the trains travel between two points, along a single section of track, going in
opposite directions. The function should consume the trains' speeds and the starting distance
between the trains. Speed is distance/time
(define (collide ts1 ts2 sd)
(define x1 (/ sd ts1))
(define x2 (/ sd ts2))
(if (< x1 x2) x1 x2)
)

10. Develop a function that when given an initial amount of money (called the principal), a simple
annual interest rate, and a number of months will compute the balance at the end of that
time. Assume that no additional deposits or withdrawals are made and and that a month is
1/12 of a year. Total interest is the product of the principal, the annual interest rate expressed
as a decimal, and the number of years.
(define (SI p t r)
(/ (* p (* (/ t 12) r)) 100)
)

11. Ms. Sis Y. Fuss wants to push a rock up a hill. The distance is d yards. In one minute, she
pushes the rock 30 yards, but then it slides down 4 yards. When she has reached d yards, it
won't slide down anymore. How many (entire) minutes will it take her?
(define (push-rock d)
(push d 0 0)
)
(define (push d cp n)
(if (or (= d cp) (< d cp)) (apply n (display "times pushed"))
(apply
(+ cp 30)
(- cp 4)
(push d cp (+ n 1))
)
)
)
12. Develop a function that takes the radii of two spheres, one of which is inside the other, and
computes the volume of the larger sphere not occupied by the smaller sphere. The volume of
a sphere is (4 * pi * r^3)/3.
(define cube (lambda (x) (* (* x x) x) ))
(define spherevolume (lambda (r) (/(* (* 3.14 (cube r)) 4)3) ) )
(define spaceleft
(lambda (R r)
( - (spherevolume R) (spherevolume r))
)
)

13. When cooking for large groups of people even small amounts of ingredients listed in a recipe
can become considerable quantities. Develop a series of functions to convert between the
given English liquid measuring units, then compose them to develop a function, Tsp->Barrels.
Here are some useful facts: 16 Tbsp = 1 Cup; 16 Cup = 1 Gal; 42 Gal = 1 Barrel.
(define tbspToCup (lambda (x) (*(/ 1 16)x) ) )
(define cupToGal (lambda (y) (*(/ 1 16)y) ) )
(define GalToBarrel (lambda (z) (*(/ 1 42)z) ) )
(define TbspToBarrel
(lambda (tablespoons)
( GalToBarrel
( cupToGal
(tbspToCup tablespoons)
)
)
)
)

14. Develop the function collision-speed. The function consumes the masses and velocities of two
objects traveling along a track that are involved in a collision that results in the objects being
stuck together. The function produces the velocity of the resulting object.......Here's some
information to help you. Since the object are traveling towards each other, one of them will
have a positive velocity and the other a negative one. Each object has a mass (m) and a
constant velocity (v). The product of mass and velocity is called momentum. A particular
collision of two objects combines the two masses and preserves the momentum. More
precisely, the momentum of the resulting object is the sum of the initial two momenta.
Consequently, the velocity of the new object is the result of dividing the new momentum by
the combined mass.
; Equations used :
;(m1 + m2) V = m1v1 – m2v2
;=> V = (m1v1 – m2v2)/(m1+m2)
(define collisionSpeed
(lambda (m1 m2 v1 v2)
(/ (- (* m1 v1) (* m2 v2)) (+ m1 m2))
)
)

15. Develop the function total-cost. The function consumes the selling price of a house and the
amount of the down payment, then produces the grand total paid by the buyer at the end of
the loan…….The following terms apply. The mortgage is financed for 30 years. The base
interest rate is a simple 8.0% per year. Extra fees total $1000…..Here are some hints: the
principal is the difference between the selling price and the down payment; only the principal
is used in calculating the interest; the total cost of the loan is the selling price plus the interest
plus any fees.
;Equations used :
;Principal =SP – DP
;Grand total finally paid = SP + (principal*30*0.08) + 1000
(define principal (lambda (SP DP) ( - SP DP) ) )
(define interest (lambda (principal) ( * (* 30 0.08) principal) ) )
(define total-cost
(lambda (SP DP)
( + ( + SP 1000) (interest principal) )
)
)

16. Develop the function within?, which consumes three numbers representing the x and y
coordinates of a point and the radius r of a circle centered around the origin It returns true if
the point is within or on the circle. It returns false otherwise. The distance of the point to the
origin is the square root of x2 + y2.
(define distanceFromCenter (lambda ( x y) (sqrt (+(* x x ) (* y y))) ) )
(define within?
(lambda (x y r)
( if (< (distanceFromCenter x y) r )
TRUE
FALSE
)
)
)

17. Develop the function within?, which consumes three numbers representing the x and y
coordinates of a point and the radius r of a circle centered around the origin It returns true if
the point is within or on the circle. It returns false otherwise. The distance of the point to the
origin is the square root of x2 + y2.
( define pr
(lambda (x y r)
(<= (sqrt (+ (* x x) (* y y))) r)))

18. A local discount store has a policy of putting labels with dates on all of its new merchandise. If
an item has not sold within two weeks the store discounts the item by 25% for the third week,
50% for the fourth week, and 75% for the fifth week. After that no additional discounts are
given.
Develop the function new-price, which takes the initial price of an item and the number of
weeks since the item was dated and produces the selling price of the item.
( define new-price
(lambda ( initial-price no-of-weeks )
(cond
[( < no-of-weeks 2) initial-price]
[( < no-of-weeks 3) (* 0.75 initial-price)]
[( < no-of-weeks 4) (* 0.5 initial-price)]
[else (* 0.25 initial-price)]
)))

19. A manufacturing company measured the productivity of its workers and found that between
the hours of 6am and 10am they could produce 30 pieces/hour/worker; between 10am and
2pm they could produce 40 pieces/hour/worker; and between 2pm and 6pm they could
produce 35 pieces/hour/worker.
Develop a function that takes an hour of the day between 6am and 6pm, in twenty-four hour
format, along with the number of workers and computes the total number of pieces produced
during that hour.
( define no-of-pieces
(lambda ( hour no-of-workers)
(cond
[(and ( >= hour 6) (< hour 10)) (* 30 no-of-workers)]
[(and ( >= hour 10) (< hour 14)) (* 40 no-of-workers)]
[(and ( >= hour 14) (< hour 18)) (* 35 no-of-workers)]
)))

20. Drop a rubber ball from a height h. Each time it hits the ground, the ball bounces up to 2/3 of
the height it dropped. Develop a function that computes how far the ball travels by the time it
hits the ground for the third time? Hint: try 36[in] for the initial height.
(define bouncing
(lambda(h n)
(if (= h 0)
0
(if (= n 0)
(display h)
(bouncing (/ (* h 2) 3) (- n 1))))))

21. Develop the program height, which computes the height that a rocket reaches in a given
amount of time. If the rocket accelerates at a constant rate g, it reaches a speed of g · t in t
time units and a height of 1/2 * v * t where v is the speed at t.
(define height
(lambda (g t)
(* (/ 1 2) (* g t) t)))

22. Develop the program Celsius->Fahrenheit, which consumes a temperature measured in


Celsius and produces the Fahrenheit equivalent.
(define euro
(lambda (dollar)
(* 0.6676 dollar)))

23. An old-style movie theater has a simple profit function. Each customer pays $5 per ticket.
Every performance costs the theater $20, plus $.50 per attendee. Develop the function totalprofit.
It consumes the number of attendees (of a show) and produces how much income the
attendees produce
(define income
(lambda (attendees)
(- (* attendees 5) (+ 20 (* attendees 0.5)))))

24. Some credit card company pay back a small portion of charges a customer makes over a year.
it returns
1. 0.25% for d 1st $500 charges
2. 0.50% for d next $1000 charges (that is from 500 to 1500 charges)
3. 1.0% for d remaining charges above $1500
define d function 'pay-back' which consumes a charge amount and computes d corresponding
pay back amount.
(define pay-back
(lambda (dollars)
(cond
[(< dollars 500)
(* dollars 0.0025) ]
[(and (> dollars 500) (< dollars 1500))
(* dollars 0.0050)]
[(> dollars 1500)
(* dollars 0.0010)])))
25. Develop a function which accepts 3 numbers and compute their sum and average
(define (num a b c)
(let* ([sum (sum a b c)]
[avg (avg a b c)])
(list sum avg)))
(define (avg x y z)(/ (+ x y z) 3))
(define (sum x y z)(+ x y z))
(num 3 9 3)
26. Develop a function which accepts the radius of circle and computes the area and its perimeter
(define pie 22/7)
(define (num a)
(let* ([area (ar a)]
[peri (per a)])
(list area peri)))
(define (ar x)(* pie x x))
(define (per x)(* 2 pie x))
(num 7)
formula
area=PI*RADIUS*RADIUS
perimeter=2*PI*RADIUS

27. Develop a function to accept a number and print if it is an odd number


(define (num a)(
if(= (remainder a 2) 1)
a
'even))
(num 6)

28. Develop a program to accept two numbers and check whether they are equal or unequal
(define (num a b)(
if(eq? a b)
'yes
'no))
(num 6 6)

29. Develop a program to accept three integers and print largest among them
(define (num a b c)(
cond
((and (> a b) (> a c)) a)
((and (> b a) (> b c)) b)
(else c)))
(num 8 34 7)

30. Develop a function to print sum of first 50 natural numbers


(define (num a)(/ ( *(+ a 1) a) 2))
(num 50 )

31. Develop a function accept a name and type the name desired number of time
(define qwe(lambda (ab n)(name ab n)))
(define name(lambda (ab n)(
(display ab)
(newline)
( if(= n 1)'end
(name ab (- n 1))))))
(name 'karan 10).

32. Develop a function to find sum of all odd integers between 1 to 50


(define qwe(lambda(n)(num 0 n)))
(define num(lambda(sum r)(if(= 1 r)sum
(if(=(remainder r 2)1)
(num (+ sum r) (- r 1))
(num sum (- r 1))))))
(qwe 50)

33. Develop a function to arrange a set of integers in a list in ascending order and
print them
(define li(list 6 7 9 5))
(sort li <)

34. Develop a function to print the largest element in a list


(define li(list 6 7 9 5))
(cond
((and (> (list-ref li 0) (list-ref li 1)) (> (list-ref li 0) (list-ref li 2)) (> (list-ref li 0)
(list-ref li 3)))(list-ref li 0))
((and (> (list-ref li 1) (list-ref li 0)) (> (list-ref li 1) (list-ref li 2)) (> (list-ref li 1)
(list-ref li 3)))(list-ref li 1))
((and (> (list-ref li 2) (list-ref li 0)) (> (list-ref li 2) (list-ref li 1)) (> (list-ref li 2)
(list-ref li 3)))(list-ref li 2))
(else (list-ref li 3)))
----------------------OR------------------
(define li(list 6 7 9 5 3 9 4 99 73 82 5 92))
(define li1(sort li <))
(car (reverse li1))

35. Develop a function to search a desired element in a set of n numbers


(define li(list 6 7 9 5 3 9 4 99 73 82 5 92))
(define (num a)(
if (member a li)a
(display "not a member")
))
(num 10)

36. Write a higher-order procedure make-list-scaler that takes a single number scale
and returns a procedure that, when applied to a list lst of numbers, will return the
list obtained by multiplying each element of lst by scale. Thus, you might have the
following interaction:
(define scale-by-5 (make-list-scaler 5))
(scale-by-5 '(1 2 3 4)) should give (5 10 15 20)
(define num(lambda (x)(map (lambda(n)(* n x)) '(1 2 3 4))))
(num 5)

37. Write a procedure that will find the position of the largest element in a nonempty
list.
(define num(lambda (x)(li x 0 (car (sort x >)))))
(define li(lambda(x i w)(
cond
((and(< i (length x))(=(list-ref x i) w))i)
((>= i (length x))(display "number not found "))
(else (li x (+ i 1) w)))))
(num '(4 9 2 67 45 2) )

38. Write a procedure that will intake a numeral and an arithmetic operator and will do the need
full as per the arithmetic operator
eg:if list is (1 2 3 4), user enters 4 and + then we shld get the output as (5 6 7 8) or user
enters 6 and * then we shld get the output as (6 12 18 24)
(define num(lambda (x c)(map (lambda(n)(c n x)) '(1 2 3 4))))
(num 5 -)

39. Develop a function that computes the distance a boat travels across a river, given the width of
the river, the boat's speed perpendicular to the river, and the river's speed. Speed is
distance/time, and the Pythagorean theorem is c2 = a2 + b2. (may to calculate time)
(define cal-time
(lambda (rw bs)
(/ rw bs)))
(define vertical-dist-travelled
(lambda (rs time)
(* rs time)))
(define square
(lambda (x) (* x x)))
(define pythagoras-thm
(lambda (side1 side2)
(sqrt (+ (square side1) (square side2)))))
(define total-dist-travelled
(lambda (rw rs bs)
(pythagoras-thm rw (vertical-dist-travelled rs (cal-time rw bs)))))

40. Bubble Sorting


;;BUBBLE SORT
(display "enter no of elements to be sorted")
(newline)
(define n (read))
(display "enter your elements one by one")
(newline)
(define a (make-vector n))
(define k 0)
(define loop
(lambda (k)
(if (< k n)
(begin
(vector-set! a k (read))
(set! k (+ k 1))
(loop k)))))
(loop k)
(define i 1)
(define temp 0)
(define j 0)
(define loop1
(lambda (i)
(if (< i n)
(begin
(set! j 0)
(loop2 j)
(set! i (+ i 1))
(loop1 i)))))
(define loop2
(lambda (j)
(if (< j (- n i))
(begin
(if (> (vector-ref a j) (vector-ref a (+ j 1)))
(begin
(set! temp (vector-ref a j))
(vector-set! a j (vector-ref a (+ j 1)))
(vector-set! a (+ j 1) temp)
(set! j (+ j 1))
(loop2 j))
(begin
(set! j (+ j 1))
(loop2 j)))))))
a
(loop1 i)
(newline)
a

41. Reversing a 3 digit number


(define rev 0)
(define rem 0)
(define (loop n)
(if (> n 0)
(begin
(set! rem (remainder n 10))
(set! rev(+ (* rev 10) rem))
(set! n (floor(/ n 10)))
(loop n))
(display rev)))
(display "Enter Number to be reversed : ")
(define n (read))
(loop n)

42. Factorial Of A Number Using Recursion


(define (fact n)
(if (= n 0)
1
(* n (fact (- n 1 )))))
(display "Enter The Number to Find The Factorial : ")
(define n(read))
(display "The Factorial Is : ")
(fact n)

43. Fibonacci Series


(define a 0)
(define b 1)
(define c 0)
(define (loops n)
(if (= n 2)
(begin
(newline)
(display "end of series"))
(begin
(fab a b)
(loops (- n 1)))
)
)
(define (fab x y)
(set! c (+ x y))
(display c)
(newline)
(set! a b)
(set! b c)
)
(display "Enter the Number of Numbers you want :- ")
(define n (read))
(display a)
(newline)
(display b)
(newline)
(loops n)

44. Greatest Common Divisor of 2 numbers


(define (gcd a b)
(if (and (> a b) (= (remainder a b) 0))
b
(if (< a b)
(begin
(gcd b a))
(gcd b (remainder a b)))
))
(display "Enter the numbers -->")
(define t1 (read))
(define t2 (read))
(display "GCD of the two numbers is ---> ")
(gcd t1 t2)

45. To print the following output :


1
12
123
1234
(define (lines n)
(let loop ((i 1))
(if(or(< i n)(= i n))
(begin
(let loop ((j 1))
(if(or(< j i)(= j i))
(begin
(display j)
(display " ")
(loop (+ j 1)))))
(newline)
(loop (+ i 1))))))
(display "Enter the no. of steps")
(define n (read))
(lines n)
46. Write a program to print the odd numbers from 1 to n.
(define integers-from-to
(lambda (low high)
(if (> low high)
'()
(cons low
(integers-from-to (+ 1 low) high)))))
(define odd-nos
(lambda (ok? lst)
(cond ((null? lst)
'())
((ok? (car lst))
(cons (car lst) (odd-nos ok? (cdr lst))))
(else
(odd-nos ok? (cdr lst))))))
(odd-nos odd? (integers-from-to 1 15))

47. Write a procedure that will find the position of a particular element in a list. For
example,
(position 50 '(10 20 30 40 50 3 2 1))

48. Pallindrome
(define palindrome?
(lambda (lst)
(equal? lst (reverse lst))))
(palindrome? '(m a d a m ))

49. Write a procedure that will find the position of a particular element in a list. For
Example :(position 50 '(10 20 30 40 50 3 2 1))
the first position is 0. What should be returned if the element is not in the list? What should be
returned if the element appears more than once in the list?
(define list-position
(lambda (o l)
(let loop ((i 1) (l l))
(if (null? l) #f
(if (eqv? (car l) o) i
(loop (+ i 1) (cdr l)))))))

50. Write a procedure that will find the largest element in a nonempty list.
(define (max-list l)
(apply max l))

51. Write a procedure that will find the position of the largest element in a nonempty
list.
(define (max-pos l)
(position ((max-list l) l)) )

52. Write a procedure that, when given a positive integer n, returns a list of the first
n perfect squares.
(define (ps-list n)
(let ((lis (list)))
(let looop ((i 1))
(if (> i n) lis
(begin
(set! lis (append lis (list(* i i))))
(looop (+ i 1))
)
))))

53. Write a procedure that, when given a positive integer n, returns a list of the first
n even integers.
(define evn-list
(lambda (n)
(let ((l (list)))
(let loop((i 1))
(if (> i n) l
(begin
(if (eq? (remainder i 2) 0)
(begin
(set! l(append l(list i)))
(display " ")
(loop (+ i 1)))
(loop (+ i 1))
)))))))

54. Write a procedure that, when given a list of positive integers, returns a list of lists
of integers. Each of these lists should be the positive integers from 1 to whatever
was in the original list. For example, (list-of-lists '(1 5 3)) should give
( (1) (1 2 3 4 5) (1 2 3) )
(define sub-list
(lambda (n)
(let ((ls (list)))
(let loop((i 1))
(if (> i n) ls
(begin
(set! ls(append ls(list i)))
(display " ")
(loop (+ i 1)))
)))))
(define list-of-list
(lambda (l)
(let ((l1 (list)))
(let loop((l l))
(if (null? l) l1
(begin
(set! l1(append l1(list (sub-list (car l)))))
(display " ")
(loop (cdr l))) )))))

55. Write a procedure that will count the number of times a particular element occurs
in a given list.
(define freq
(lambda ( o l)
(cond
((memq o l) =>
(lambda (l)
(+ (freq o (cdr l)) 1)))
(else 0))))
56. Write a procedure map-2 that takes a procedure and two lists as arguments and
returns the list obtained by mapping the procedure over the two lists, drawing the
two arguments from the two lists. For example, it would yield the following results:
(map-2 + '(1 2 3) '(2 0 -5))
(3 2 -2)
(map-2 * '(1 2 3) '(2 0 -5))
(2 0 -15)
Write this procedure map-2. You may assume that the lists have the same length.
(define map-2+
(lambda (l1 l2)
(let ((la (list)))
(let loop ((l1 l1) (l2 l2))
(if (or (null? l1) (null? l2)) la
(begin
(set! la(append la(list (+ (car l1) (car l2)))))
(display " ")
(loop (cdr l1) (cdr l2))
)
)))))
for map-2* (set! la(append la(list (* (car l1) (car l2)))))
(set! la(append la(list (+ (car l1) (car l2)))))

57. Write a higher-order procedure make-list-scaler that takes a single number scale
and returns a procedure that, when applied to a list lst of numbers, will return the
list obtained by multiplying each element of lst by scale. Thus, you might have the
following interaction: (define scale-by-5 (make-list-scaler 5))
(scale-by-5 '(1 2 3 4)) should give (5 10 15 20)
(define scale-by-5
(lambda (l)
(let ((l1 (list)))
(let loop((l l))
(if (null? l) l1
(begin
(set! l1(append l1(list (* (car l) 5))))
(display " ")
(loop (cdr l)))
)))))

58. Create a structure called deposit which holds the fields depositor name, deposit amount, no. of
.years. Get a list of depositors calculate the simple interest and credit back the new amount to
the list and display d list. If no.of.years is 1 then rate is 8%, if its 2 rate 9% more than 2yrs
will be 10%...etc
(define-struct deposit(depositor_name yrs amt))
(define revised
(lambda (a-deposit)
(define (check a-deposit)
(cond
[(eq? (deposit-yrs a-deposit) '1)
(+ (deposit-amt a-deposit) (* (deposit-amt a-deposit) 0.08))]
[(eq? (deposit-yrs a-deposit) '2)
(+ (deposit-amt a-deposit) (* (deposit-amt a-deposit) 0.09))]
[else (+ (deposit-amt a-deposit) (* (deposit-amt a-deposit) 0.1))]))
(display "Name-->")
(display (deposit-depositor_name a-deposit))
(newline)
(display "Amount-->Rs.")
(display (check a-deposit))
(newline)
(display "Years-->")
(display (deposit-yrs a-deposit))))
(revised (make-deposit 'jit '2 '6532))
(newline)
(revised (make-deposit 'pupu '1 '7532))
(newline)
(revised (make-deposit 'tarun '5 '8236))

59. create a 'student' structure with d properties (last,first,teacher) and create a function 'check'
which will return d last name of d student if d teacher's name is equal to d name entered by d
user(i.e. a-teacher) and 'none otherwise
(define-struct student (last first teacher))
(define (check a-student a-teacher)
(cond
[(symbol=? (student-teacher a-student) a-teacher)
(student-last a-student)]
[else 'none]))
(check (make-student 'jit 'tarafdar 'tarun) 'tarun)

60. Create a structure vehicle with attributes name, reg_no and price create some instances and
display the revised list of vehicles if prices are revised or display original list....some thing like
that
(define-struct veh (name reg price))
(define (disp lis)
(let loop ((l lis))
(if (null? l) (newline)
(begin
(display (veh-name (car l)))
(display " ")
(display (veh-reg (car l)))
(display " ")
(display (veh-price (car l)))
(newline)
(loop (cdr l))))))
(define (update a-veh)
(cond
[(equal? (veh-reg a-veh) (read))
(make-veh (veh-name a-veh) (veh-reg a-veh) (+ (veh-price a-veh) (* (veh-price aveh)
0.1)))]
[else a-veh]))
(disp (list (update (make-veh 'honda 1101 25000)) (update (make-veh 'Bajaj 1102
26000))))

61. To create a function to calculate the total amount in rupees, earned by a theater in one show
which takes five arguments, no of adults, no of children, adult fare, children fare, (fare in
dollars), dollar equivalent rupee value.
(define (tot_ear noa noc af cf val)
(begin
(display "Total earning by theatre")
(newline)
(display "In dollars --> $")
(display (+ (* noa af) (* noc cf)))
(newline)
(display "In rupees --> Rs.")
(display (* (+ (* noa af) (* noc cf)) val))))
(display "Enter no. of adults")
(define noa (read))
(display "Enter no. of children")
(define noc (read))
(display "Enter ticket fare of Adult")
(define af (read))
(display "Enter ticket fare of children")
(define cf (read))
(display "Enter value of $ to Rs")
(define val (read))
(tot_ear noa noc af cf val)

Vous aimerez peut-être aussi