he 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
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-
Step by step
Solved in 4 steps with 1 images