Arithmetic Exception   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 Variable Name string name string type double 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:  0 Arithmetic Exception:Number of days 0 is invalid

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter11: More Object-oriented Programming Concepts
Section: Chapter Questions
Problem 20RQ
icon
Related questions
Question
Arithmetic Exception

 

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 Variable Name
string name
string type
double 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:
 0
Arithmetic Exception:Number of days 0 is invalid
 

 

 

Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Random access
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
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage