QQQ
QQQ
Roy is a wholesale cloth dealer who sells cloth material to the local tailors on
monthly installments. At the end of each month, he collects the installment amount
from all his customers. Some of his customers pay by Cheque, some pay by Cash and
some by Credit Card. He wants to automate this payment process.
The application needs to verify the payment process and display the status report
of payment by getting the inputs like due amount, payment mode and data specific to
the payment mode from the user and calculate the balance amount.
Component Name
Type(Class)
Attributes
Methods
Responsibilities
Payment
int dueAmount
Payment
The boolean payAmount() method should return true if there is no due to be paid,
else return false.
Note:
Component Name
Type(Class)
Attributes
Methods
Responsibilities
Cheque
String chequeNo
int chequeAmount
Date dateOfIssue
Include a public getter and setter method for all the attributes.
Cheque
This is an overridden method of the parent class. It should return true if the
cheque is valid and the amount is valid. Else return false.
Note:
Component Name
Type(Class)
Attributes
Methods
Responsibilities
Cash
int cashAmount
Cash
This is an overridden method of the parent class. It should return true if the
cashAmount is greater than or equal to the dueAmount. Else return false.
Component Name
Type (Class)
Attributes
Methods
Responsibilities
Credit
int creditCardNo
String cardType
int creditCardAmount
Include a public getter and setter method for all the attributes.
Credit
This is an overridden method of the parent class. It should deduct the dueAmount
and service tax from the creditCardAmount and return true if the credit card
payment was done successfully. Else return false.
Note:
· The payment can be done if the credit card amount is greater than or equal
to the sum of due amount and service tax. Else payment cannot be made.
Service Tax
silver
10000
gold
50000
platinum
100000
· The boolean payAmount() method should deduct the due amount and the
service tax amount from a credit card. If the creditCardAmount is less than the
dueAmount+serviceTax, then the payment cannot be made.
Component Name
Type(Class)
Attributes
Methods
Responsibilities
Bill
public String processPayment (Payment obj)
This method should return a message based on the status of the payment made.
Note:
· If the payment is a failure, then return a message “Payment not done and
your due amount is <<dueAmount>>”
Create a public class Main with the main method to test the application.
Note:
Sample Input 1:
3000
Enter the mode of payment(cheque/cash/credit):
cash
Enter the cash amount:
2000
Sample Output 1:
Sample Input 2:
Enter the due amount:
3000
Enter the mode of payment(cheque/cash/credit):
cash
Enter the cash amount:
3000
Sample Output 2:
Sample Input 3:
3000
Enter the mode of payment(cheque/cash/credit):
cheque
Enter the cheque number:
123
Enter the cheque amount:
3000
Enter the date of issue:
21-08-2019
Sample Output 3:
Sample Input 4:
3000
Enter the mode of payment(cheque/cash/credit):
credit
Enter the credit card number:
234
Enter the card type(silver,gold,platinum):
silver
Sample Output 4:
Payment done successfully via credit card. Remaining amount in your silver card is
6940
file
================
///main.java
------------------------------
public class Main {
// payment.java
------------------------
public class Payment {
private int dueAmount;
return isPaid;
}
// Cheque.java
-----------------------------------
public class Cheque {
// Cash.java
----------------------------------
public class Cash {
// Creadit.java
----------------------------
}
//Bill.java
--------------------------
public class Bill {
return result;
}