Question
Core Java_Exception Handling_CC Problem 1 Sathish is an Oil merchant and he sells his pure, hygienically prepared Oil supplies to retailers and dealers across Cities.
Core Java_Exception Handling_CC Problem 1
Sathish is an Oil merchant and he sells his pure, hygienically prepared Oil supplies to retailers and dealers across Cities. His customers pay him through Cash, Cheque and sometimes through Credit/Debit Cards. Sathish faced a lot of problem during the payment transactions, especially while processing with Cheques. He found that in most of the Cheques given by his Customers, incorrest dates were given. So create a program to validate the dates in the Cheques. The program should collect the Cheque details from the Customers and validate the date in the Cheque, a Cheque is valid only if the cheque is dated within 3 months from the current date (assume a current date). Write a program that will throw an exception if the date on the cheque is invalid if not will print a message "Cheque is sent to clearing house". Create a class named Cheque with the following private member variables / attributes
String bankName
String chequeNumber
Date chequeDate
Include 3 argument constructor with argument order bankName,chequeNumber,chequeDate.
Include appropriate getters and setters.
Create a class named PaymentBO with the method processPayment. --- processPayment(Cheque) to find whether the cheque is valid or not.Cheque is said to be valid if date is within three months from current date.Assume that current date is15/05/2017.
S.No | Method Name | Method description |
1 | boolean processPayment(Cheque cheque) | to check whether the chequeDate is valid or not,if valid return true or throw InvalidDateException. |
Create another class Main and write a main method to test the above class. Problem Specification: 1) Create an custom exception named as InvalidDateException. 2) Display "Cheque is sent to clearing house" when cheque is valid or throw an invalid date exception. 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. [Note :Strictly adhere to the object oriented specifications given as a part of the problem statement.Use the same class names, method names and attribute names.] Sample Input and Output 1: Enter the cheque details Enter the bank name : AGSC bank Enter the cheque number : 248736482773845 Enter the cheque date : 12/05/2017 InvalidDateException: Cheque is valid only for three months Sample Input and Output 2: Enter the cheque details Enter the bank name : AGSC Enter the cheque number : 249374537474 Enter the cheque date : 15/05/2017 Cheque is sent to clearing house
Here, I am providing the piece of code. Please update it and send me back.
Main.java
import java.io.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Main {
public static void main(String args[]){
}
}
PaymentBO.java
import java.text.ParseException;
import java.text.SimpleDateFormat;
public class PaymentBO {
}
InvalidDateException.java
public class InvalidDateException{
}
Cheque.java
import java.util.Date;
public class Cheque {
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started