Arman has a shop where he provides stuff on rent. The whole payment system is computerised. A customer has to enter the item name, item type, cost, and the number of days they have taken the item for rent. The system then tells them the cost per day. But there is a problem with the machine that if the number of days entered is not an integer value then the system would crash. To handle this, Arman decided to upgrade the software and use exception handling in case the customer entered any invalid input it should display "Number of days x is invalid". Write a C++ program to find the item cost per day with the cost for n days given. The arithmetic exception has to be thrown if the n is less than or equal to zero. 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 Item has the following private data members. Data type string string double Variable Name name type cost In the main method, get the necessary inputs and number of days from the user and display the item details, if the number of days is not less than or equal to zero. Input and output format: Display the Item Details with cost per day with respect to two decimal places. 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 item name: table Enter item type: furniture Enter item cost: 30000 Enter number of days: 30 Item name:table Item type:furniture Item cost day:1000.00 Sample Input and Output 2: Enter item name: pen Enter item type: stationary Enter item cost: 2762 Enter number of days: Arithmetic Exception:Number of days 0 is invalid

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

QUESTION PROVIDED IN ATTACH IMAGE KINDLY SEE.

AND MATCH OUTPUT WITH QUESTION OUTPUT AS IT IS.

 

TEMPLATE PROVIDED BELOW USES IT WHILE MAKING SOLUTIONS.

------------------------------------------------------------------------------

MAIN.CPP

#include <iostream>
#include "Item.cpp"
using namespace std;
int main()
{
string name,type;
double cost;
double costperday;
int n;

Item it;
cout<<"Enter item name:"<<endl;
cin>>name;
it.setName(name);
cout<<"Enter item type:"<<endl;
cin>>type;
it.setType(type);
cout<<"Enter item cost:"<<endl;
cin>>cost;
it.setCost(cost);
cout<<"Enter number of days:"<<endl;
cin>>n;

// Fill the code to handle the Arithmetic Exception

return 0;
}

 

 

Item.cpp

#include <iostream>
#include <stdio.h>

using namespace std;

class Item
{
private:
string name,type;
double cost;
public:
void setName(string name)
{
this->name=name;
}
void setType(string type)
{
this->type=type;
}
void setCost(double cost)
{
this->cost=cost;
}
string getName()
{
return this->name;
}
string getType()
{
return this->type;
}
double getCost()
{
return this->cost;
}
};

Arman has a shop where he provides stuff on rent. The whole payment system is computerised. A
customer has to enter the item name, item type, cost, and the number of days they have taken the item
for rent. The system then tells them the cost per day. But there is a problem with the machine that if
the number of days entered is not an integer value then the system would crash. To handle this, Arman
decided to upgrade the software and use exception handling in case the customer entered any invalid
input it should display " Number of days x is invalid".
Write a C++ program to find the item cost per day with the cost for n days given. The arithmetic
exception has to be thrown if the n is less than or equal to zero.
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 Item has the following private data members.
Data type
string
string
double
Variable Name
name
type
cost
In the main method, get the necessary inputs and number of days from the user and display the item
details, if the number of days is not less than or equal to zero.
Input and output format:
Display the Item Details with cost per day with respect to two decimal places.
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 item name:
table
Enter item type:
furniture
Enter item cost:
30000
Enter number of days:
30
Item name:table
Item type:furniture
Item cost per day:1000.00
Sample Input and Output 2:
Enter item name:
pen
Enter item type:
stationary
Enter item cost:
2762
Enter number of days:
Arithmetic Exception:Number of days 0 is invalid
Transcribed Image Text:Arman has a shop where he provides stuff on rent. The whole payment system is computerised. A customer has to enter the item name, item type, cost, and the number of days they have taken the item for rent. The system then tells them the cost per day. But there is a problem with the machine that if the number of days entered is not an integer value then the system would crash. To handle this, Arman decided to upgrade the software and use exception handling in case the customer entered any invalid input it should display " Number of days x is invalid". Write a C++ program to find the item cost per day with the cost for n days given. The arithmetic exception has to be thrown if the n is less than or equal to zero. 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 Item has the following private data members. Data type string string double Variable Name name type cost In the main method, get the necessary inputs and number of days from the user and display the item details, if the number of days is not less than or equal to zero. Input and output format: Display the Item Details with cost per day with respect to two decimal places. 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 item name: table Enter item type: furniture Enter item cost: 30000 Enter number of days: 30 Item name:table Item type:furniture Item cost per day:1000.00 Sample Input and Output 2: Enter item name: pen Enter item type: stationary Enter item cost: 2762 Enter number of days: Arithmetic Exception:Number of days 0 is invalid
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

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