Hére is a summary of that table: • A recipient can receive blood from anyone with the same blood type. A person with O- blood can be a donor for anyone. A person with AB+ blood can receive blood from anyone. • Additonally, a person with AB- blood can receive blood from a donor with B- or A- blood. Additonally, a person with A+ blood can receive blood from a donor with O+ or A- blood. • Additonally, a person with B+ blood can receive blood from a donor with O+ or B- blood. • No other combination of donor and recipient blood types is compatible. For this question, we will use symbols to represent each blood type. The symbol will match the types described above. So for example, the O+ blood type w will be one of the blood types described above. Write a function compatible-litres in Racket that consumes a list of symbols, blood-bank, and a symbol, blood-type. Each element in blood-bank reE and blood-type represents the blood type of a blood transfusion recipient. The function produces the total number of litres available for donation for some bank. For example: * 1 > (compatible-litres (list '0- '0+ '0- 'B- 'AB-) 'AB-) 2 2 3> (compatfible-litres (list 'A+ 'B+) 'A-) 4 0 5 > (compatible-litres (list 'A+ 'B+ 'AB+) 'AB+) 6 1.5

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter10: Classes And Data Abstraction
Section: Chapter Questions
Problem 19PE
icon
Related questions
Question
Question 1: Blood Donation For this question you will be writing a program to solve the same problem as Question 2 from Assignment 4. However, as described at the beginning of the assignment specification your solution for this assignment must not use explicit recursion. Since the purpose, contract, and examples would be identical to the solution for the Assignment 4. However, you are encouraged to properly document and fully test your solution. You are welcome to use code and tests from the model solution in your submission for this question. Here is the problem specification. Hospitals rely on donors to provide blood for people who are in accidents or scheduled for surgery. However, people have different blood types, and some blood types are compatible for donation and others are not. There are eight different blood types: O-, O+, B-, B+, A-, A+, AB-, AB+ The rules for blood donations are shown in a table from the Canadian Blood Services website. Here is a summary of that table: * A recipient can receive blood from anyone with the same blood type. * A person with O- blood can be a donor for anyone. * A person with AB+ blood can receive blood from anyone. * Additonally, a person with AB- blood can receive blood from a donor with B- or A- blood. * Additonally, a person with A+ blood can receive blood from a donor with O+ or A- blood. * Additonally, a person with B+ blood can receive blood from a donor with O+ or B- blood. * No other combination of donor and recipient blood types is compatible. For this question, we will use symbols to represent each blood type. The symbol will match the types described above. So for example, the O+ blood type will be represented by the symbol 'O+. All symbols in the question will be one of the blood types described above. Write a function compatible-litres in Racket that consumes a list of symbols, blood-bank, and a symbol, blood-type. Each element in blood-bank represents a 0.5 litre donation of the matching blood type symbol, and blood-type represents the blood type of a blood transfusion recipient. The function produces the total number of litres available for donation for someone with the given blood-type given the donations in blood-bank. For example: 1 2 3 4 5 6 > (compatible-litres (list 'O- 'O+ 'O- 'B- 'AB-) 'AB-) 2 > (compatible -litres (list 'A+ 'B+) 'A-) 0 > (compatible-litres (list 'A+ 'B+ 'AB+) 'AB+) 1.5 > (compatible-litres (list 'O- 'O+ 'O- 'B- 'AB-) 'AB-) 2 > (compatible-litres (list 'A+ 'B+) 'A-) 0 > (compatible-litres (list 'A+ 'B+ 'AB+) 'AB+) 1.5
Here is a summary of that table:
• A recipient can receive blood from anyone with the same blood type.
• A person with O- blood can be a donor for anyone.
• A person with AB+ blood can receive blood from anyone.
Additonally, a person with AB- blood can receive blood from a donor with B- or A- blood.
• Additonally, a person with A+ blood can receive blood from a donor with O+ or A- blood.
Additonally, a person with B+ blood can receive blood from a donor with O+ or B- blood.
• No other combination of donor and recipient blood types is compatible.
For this question, we will use symbols to represent each blood type. The symbol will match the types described above. So for example, the O+ blood type will
will be one of the blood types described above.
Write a function compatible-litres in Racket that consumes a list of symbols, blood-bank, and a symbol, blood-type. Each element in blood-bank rep
and blood-type represents the blood type of a blood transfusion recipient. The function produces the total number of litres available for donation for somec
bank.
For example:
> (compatible-litres (list '0- '0+ '0- 'B- 'AB-) 'AB-)
2 2
3 > (compatfible-litres (list 'A+ 'B+) 'A-)
4 0
5 > (compatible-litres (list 'A+ 'B+ 'AB+) 'AB+)
6 1.5
Submit your solution in the file a08ql.rkt.
Transcribed Image Text:Here is a summary of that table: • A recipient can receive blood from anyone with the same blood type. • A person with O- blood can be a donor for anyone. • A person with AB+ blood can receive blood from anyone. Additonally, a person with AB- blood can receive blood from a donor with B- or A- blood. • Additonally, a person with A+ blood can receive blood from a donor with O+ or A- blood. Additonally, a person with B+ blood can receive blood from a donor with O+ or B- blood. • No other combination of donor and recipient blood types is compatible. For this question, we will use symbols to represent each blood type. The symbol will match the types described above. So for example, the O+ blood type will will be one of the blood types described above. Write a function compatible-litres in Racket that consumes a list of symbols, blood-bank, and a symbol, blood-type. Each element in blood-bank rep and blood-type represents the blood type of a blood transfusion recipient. The function produces the total number of litres available for donation for somec bank. For example: > (compatible-litres (list '0- '0+ '0- 'B- 'AB-) 'AB-) 2 2 3 > (compatfible-litres (list 'A+ 'B+) 'A-) 4 0 5 > (compatible-litres (list 'A+ 'B+ 'AB+) 'AB+) 6 1.5 Submit your solution in the file a08ql.rkt.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Events
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Operations Research : Applications and Algorithms
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage