Given a problem and correct (shuffled) program, re-arrange the shuffled code segments in the correct order. ------------------------------------------ ATM machines are nowadays more in use, people are easily able to withdraw money from the ATM, instead of rushing to the bank and waiting in a long queue to get money. But there are people who don't know, how to use ATM machines and they are not aware of the money withdrawal range. Write a  c++ program to help them using the Exception handling mechanism. Pin number should be of 4 digits, an exception should be thrown if the user enters more than 4 digits(refer to sample input and output) The maximum amount that can be withdrawn is Rs.20000, an exception should be thrown if the user enters more than Rs.20000(refer to sample input and output.) Consider a class named Atm with the following data members Data type Variable name int pin double amount   The class Atm has the following constructor and method Member Function Description Atm(int pin,double amount) Sets the values passed by parameters. void display() This method displays the success message.   Input and Output Format: Refer sample input and output for formatting specifications [All text in bold corresponds to input and the rest corresponds to output] Sample Input and Output 1: Welcome to IndusLand Bank ATM Enter your pin number 12345 Exception: Pin number should be of 4 digit Enter your valid pin number 1234 Enter the transaction amount 30000 Exception: Transaction amount exceeded, the limit is Rs.20000 Enter the transaction amount again 20000 Transaction successful, visit again Sample Input and Output 2: Welcome to IndusLand Bank ATM Enter your pin number 4556 Enter the transaction amount 19000 Transaction successful, visit again ------------------------Question ends-------------------------------- the shuffled program given below don't change or add anything in it just rearrange below code . ------------------------------------------- #include #include #include    #include  using namespace std; class Atm {   int pin; double amount; cout<<"Welcome to IndusLand Bank ATM"<>amount; }   throw "Exception: Pin number should be of 4 digit"; } }   catch(const char* msg) { cerr << msg << endl;   cin>>pin; if(!(pin >=1000 && pin<=9999)) {   // Main function for the program int main( ) {   cout <<"Enter your valid pin number"<>pin; }   } Atm(int pin,double amount) {   try { cout <<"Enter the transaction amount"<pin = pin; this->amount = amount; }   Atm a(pin,amount); a.display(); return 0;   cin>>amount; if(amount>20000) {

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

Given a problem and correct (shuffled) program, re-arrange the shuffled code segments in the correct order.

------------------------------------------
ATM machines are nowadays more in use, people are easily able to withdraw money from the ATM, instead of rushing to the bank and waiting in a long queue to get money. But there are people who don't know, how to use ATM machines and they are not aware of the money withdrawal range. Write a  c++ program to help them using the Exception handling mechanism.

Pin number should be of 4 digits, an exception should be thrown if the user enters more than 4 digits(refer to sample input and output)

The maximum amount that can be withdrawn is Rs.20000, an exception should be thrown if the user enters more than Rs.20000(refer to sample input and output.)

Consider a class named Atm with the following data members
Data type Variable name
int pin
double amount

 


The class Atm has the following constructor and method

Member Function Description
Atm(int pin,double amount) Sets the values passed by parameters.
void display() This method displays the success message.

 

Input and Output Format:

Refer sample input and output for formatting specifications

[All text in bold corresponds to input and the rest corresponds to output]
Sample Input and Output 1:

Welcome to IndusLand Bank ATM
Enter your pin number
12345
Exception: Pin number should be of 4 digit
Enter your valid pin number
1234
Enter the transaction amount
30000
Exception: Transaction amount exceeded, the limit is Rs.20000
Enter the transaction amount again
20000
Transaction successful, visit again

Sample Input and Output 2:

Welcome to IndusLand Bank ATM
Enter your pin number
4556
Enter the transaction amount
19000
Transaction successful, visit again

------------------------Question ends--------------------------------

the shuffled program given below don't change or add anything in it just rearrange below code .

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

#include<iostream>
#include<cmath>
#include <iomanip>
 
#include <cstring>
using namespace std;
class Atm {
 
int pin;
double amount;
cout<<"Welcome to IndusLand Bank ATM"<<endl;
public:
Atm()
{
public:
int pin;
double amount;
 
}


 
public:
void display()
{
 
try
{
cout <<"Enter your pin number"<<endl;
 
throw "Exception: Transaction amount exceeded, the limit is Rs.20000";
}
}
 
cout<<"Transaction successful, visit again"<<endl;
}
};
 
cout <<"Enter the transaction amount again"<<endl;
cin>>amount;
}
 
throw "Exception: Pin number should be of 4 digit";
}
}
 
catch(const char* msg)
{
cerr << msg << endl;
 
cin>>pin;
if(!(pin >=1000 && pin<=9999))
{
 
// Main function for the program
int main( )
{
 
cout <<"Enter your valid pin number"<<endl;
cin>>pin;
}
 
}
Atm(int pin,double amount)
{
 
try
{
cout <<"Enter the transaction amount"<<endl;
 
catch(const char* msg)
{
cerr << msg << endl;
 
this->pin = pin;
this->amount = amount;
}
 
Atm a(pin,amount);
a.display();
return 0;
 
cin>>amount;
if(amount>20000)
{
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education