Write a C++ program to add and search ItemTypes using an array, and to display whether the itemType is available or not. 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. Create class ItemType with the following private member variables. Data Type Variable Name string itemName double itemDeposit double costPerDay Create another class named ItemTypeBO and include the following member functions. Member Function strong> int searchItemTypeByName(ItemType *itemtype,int n,string searchName) This function accepts an array of itemtype, size of an array, and itemType to be searched. The function is used to search the itemType from the array of itemType using searchName. If the itemtype is available it returns 1 otherwise returns 0. ItemType createItemType(string itemName,double itemDeposit,double costPerDay) It takes itemtype name, deposit amount, cost per day as input. It creates an object of class ItemType and returns it. Note: Use Array of Objects In the main method, obtain input from the user in the console and create a new ItemType object and assign the values to the object's members using setters. Get the name of the ItemType to be searched and display whether the ItemType is found or not using SearchItemTypeByName method. Input format: The first line of input consists of an integer that corresponds to the number of item types. The following inputs correspond to item type details. The last line of input consists of a string that corresponds to the item name to be searched. Output format: The output consists of a string If the given item name is found print "ItemType found" else print "ItemType not found" If the number of item types is less than 1 print "Invalid Number" 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 Itemtypes: 2 Enter details of item type 1 Enter the Itemtype name: Stationary items Enter the deposit: 5000 Enter cost per day: 5 Enter details of item type 2 Enter the Itemtype name: Electronic items Enter the deposit: 70000 Enter cost per day: 70 Enter the item name to be searched: Stationary items ItemType found Sample Input and Output 2: Enter the number of Itemtypes: 2 Enter details of item type 1 Enter the Itemtype name: Furnitures Enter the deposit: 100000 Enter cost per day: 1000 Enter details of item type 2 Enter the Itemtype name: Food items Enter the deposit: 5000 Enter cost per day: 50 Enter the item name to be searched: Table ItemType not found Sample Input and Output 3: Enter the number of Itemtypes: -8 Invalid Number
Write a C++ program to add and search ItemTypes using an array, and to display whether the itemType is available or not.
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.
Create class ItemType with the following private member variables.
Data Type | Variable Name |
string | itemName |
double | itemDeposit |
double | costPerDay |
Create another class named ItemTypeBO and include the following member functions.
Member Function | strong> |
int searchItemTypeByName(ItemType *itemtype,int n,string searchName) | This function accepts an array of itemtype, size of an array, and itemType to be searched. The function is used to search the itemType from the array of itemType using searchName. If the itemtype is available it returns 1 otherwise returns 0. |
ItemType createItemType(string itemName,double itemDeposit,double costPerDay) | It takes itemtype name, deposit amount, cost per day as input. It creates an object of class ItemType and returns it. |
Note:
Use Array of Objects
In the main method, obtain input from the user in the console and create a new ItemType object and assign the values to the object's members using setters.
Get the name of the ItemType to be searched and display whether the ItemType is found or not using SearchItemTypeByName method.
Input format:
The first line of input consists of an integer that corresponds to the number of item types.
The following inputs correspond to item type details.
The last line of input consists of a string that corresponds to the item name to be searched.
Output format:
The output consists of a string
If the given item name is found print "ItemType found" else print "ItemType not found"
If the number of item types is less than 1 print "Invalid Number"
Refer sample input and output for formatting specifications
[All text in bold corresponds to input and rest corresponds to output]
Enter details of item type 1
Enter the Itemtype name:
Stationary items
Enter the deposit:
5000
Enter cost per day:
5
Enter details of item type 2
Enter the Itemtype name:
Electronic items
Enter the deposit:
70000
Enter cost per day:
70
Enter the item name to be searched:
Stationary items
ItemType found
2
Enter details of item type 1
Enter the Itemtype name:
Furnitures
Enter the deposit:
100000
Enter cost per day:
1000
Enter details of item type 2
Enter the Itemtype name:
Food items
Enter the deposit:
5000
Enter cost per day:
50
Enter the item name to be searched:
Table
ItemType not found
-8
Invalid Number
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 3 images