ABC Blood bank wanted to fix the cost for all types of Blood group according to the availability of them. They planned to fix the cost in such a way that the rarely available Bloodgroups are charged high compared to the others. Write a program to get the Blood group and the cost for all blood groups, help them to display the blood group with the lowest cost using a parameterized constructor.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

ABC Blood bank wanted to fix the cost for all types of Blood group according to the availability of them. They planned to fix the cost in such a way that the rarely available Bloodgroups are charged high compared to the others. Write a program to get the Blood group and the cost for all blood groups, help them to display the blood group with the lowest cost using a parameterized constructor.

Strictly adhere to the Object-Oriented specifications given in the problem statement. All class names, member variable names, and function names should be the same as specified in the problem statement.
 

The class Blood has the following private data members.

Data Type Variable Name
string blood_group 
int   cost


Include appropriate default and parameterized constructors for the above class.

Include the following method in the Blood class

Method Member Functions
void display(Blood obj[], int n) This method is used to display the details of the blood group with the lowest cost.
Display the statement ‘Blood group details:’ also inside this method.

 


Create a driver class called Main. In the main method, obtain input from the user in the console and display the details of the blood group with the lowest cost by calling the display method present in the Blood class.

Input and Output format:
Refer sample input and output for formatting specifications.

 

[All text in bold corresponds to input and rest corresponds to output]

Sample Input and Output 1:

Enter the Number of Blood groups:
2
Enter the Blood group:
A+
Enter the cost per unit:
150
Enter the Blood group:
B+
Enter the cost per unit:
100
Blood group details:
Blood group with lowest cost: B+

Sample Input and Output 2 :

Enter the Number of Blood groups:
5
Enter the Blood group:
AB-
Enter the cost per unit:
300
Enter the Blood group:
A-
Enter the cost per unit:
250
Enter the Blood group:
A+
Enter the cost per unit:
340
Enter the Blood group:
B+
Enter the cost per unit:
100
Enter the Blood group:
B-
Enter the cost per unit:
100
Blood group details:
Blood group with lowest cost: B+
B-

 

O VALIDATE
O RESET
e File (Ctrl+S)
Blood.cpp
Main.cpp/
1 #include <iostream>
2 using namespace std;
3 class Blood {
private:
string blood_group;
int cost;
public:
string bg;
int c;
4.
6.
7
8.
9.
10
11
//Fill your code here
12
void display(Blood obj[],int n){
//Fill your code here
cout<<Blood group with lowest cost:<<bg;
}
13
14
15
16
17
18
};
19
II
Transcribed Image Text:O VALIDATE O RESET e File (Ctrl+S) Blood.cpp Main.cpp/ 1 #include <iostream> 2 using namespace std; 3 class Blood { private: string blood_group; int cost; public: string bg; int c; 4. 6. 7 8. 9. 10 11 //Fill your code here 12 void display(Blood obj[],int n){ //Fill your code here cout<<Blood group with lowest cost:<<bg; } 13 14 15 16 17 18 }; 19 II
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Data members
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education