Write a C++ program to ask the number of item types, then create an array list to obtain input from the user and display the item type details using iterator loop

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Write a C++ program to ask the number of item types, then create an array list to obtain input from the user and display the item type details using iterator loop

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 named ItemType has the following private member variables.

Data Type Variable Name
string name
double deposit
double costPerDay


Define the following member function inside the class ItemTypeBO.

Function Name Description
void display (list<ItemType> item)                                                         This function is used to display the item type details in the following format, "ItemName", "ItemDeposit", "CostPerDay")
print the header "Item type details are:"  inside the display function.


In the main method, obtain item type details from the user in the console and store them in a list. Display the ItemType details in a tabular form by calling the display method. If the number of item types entered is less than or equal to zero print 'Invalid number'.

Problem constraints:
Use < iterator> containers to display the values.
Use the insert() method to insert the values.

Input and Output format:
Refer sample input and output for formatting specifications.
Display the item deposit and cost per day with respect to two decimal places.
[All text in bold corresponds to input and the rest corresponds to output]
 

Sample Input and Output 1:

Enter the number of item type:
2
Enter details of item type 1
Enter the item type name:
Electronics
Enter the deposit:
20000
Enter cost per day:
200
Enter details of item type 2
Enter the item type name:
Furniture
Enter the deposit:
30000
Enter cost per day:
300
Item type details are:
ItemName                ItemDeposit                CostPerDay               
Electronics               20000.00                    200.00              
Furniture                  30000.00                    300.00  

Sample Input and Output 2:
Enter the number of itemtypes:
-5
Invalid number

 

--------------STRICTLY USE BELOW TEMPLATE WHILE MAKING SOLUTION-------

 

MAIN.CPP

#include <iostream>
#include<string.h>
#include<list>
#include<stdio.h>
#include "ItemType.cpp"
#include "ItemTypeBO.cpp"
using namespace std;
int main()
{
// fill the code
return 0;
}

 

 

ItemtypeBo.cpp

#include <iostream>
#include<string.h>
#include<list>
#include<stdio.h>
#include"ItemType.cpp"
using namespace std;
class ItemTypeBO
{
public:
void display(list<ItemType> item){
// fill the code
}
};

 

ItemType.cpp

#ifndef ITEMTYPE_H
#define ITEMTYPE_H
#include <iostream>
#include<string.h>
#include<list>
#include<stdio.h>
using namespace std;
class ItemType
{
private:
string name;
double deposit,costPerDay;
public :
ItemType()
{
}
ItemType(string name,double deposit,double costPerDay)
{
this->name=name;
this->deposit=deposit;
this->costPerDay=costPerDay;
}
void setName(string name)
{
this->name=name;
}
void setDeposit(double deposit)
{
this->deposit=deposit;
}
void setCostPerDay(double costperday1)
{
this->costPerDay=costperday1;
}
string getItemName()
{
return name;
}
double getItemDeposit()
{
return deposit;
}
double getCostPerDay()
{
return costPerDay;
}
};
#endif
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY