ACTIVITY-8
Name: Achintya S Rao
Reg. No: 16BCI0158
Subject: Java Programming
Submitted to: Prof. Arun Kumar G
Code:
package solution;
import [Link].*;
import [Link].*;
class NegativeAmoutException extends Exception{
public NegativeAmoutException(String s){
super(s);
}
}
class InvalidMobile extends Exception{
public InvalidMobile(String k){
super(k);
}
}
class CountVariable extends Exception{
public CountVariable(String g){
super(g);
}
}
class Taxation{
String houseno;
String strname;
String address;
String areacode;
String taxno;
String ownename;
String mob;
void customerinput(){
[Link]("Enter the following details in
correct order:House no, Street name, Address, Area Code,
Taxation No, Owner Name and Mobile no respecitively ");
Scanner scn=new Scanner([Link]);
houseno=[Link]();
strname=[Link]();
address=[Link]();
areacode=[Link]();
taxno=[Link]();
ownename=[Link]();
try{
mob=[Link]();
if([Link]()!=10)
{
throw new InvalidMobile("The mobile number is
[Link] a valid number!");
}
[Link]("Reading the data is complete!");
}catch(InvalidMobile e){
[Link](e);
}
void print1(){
[Link]("Printing the Owner
details....Please wait!!");
[Link]("Taxation no:"+taxno);
[Link]("Owner name:"+ownename);
[Link]("Mobile number:"+mob);
[Link]("Extended address:"+houseno+"
"+strname+" "+address+" "+areacode);
};
}
class Bill extends Taxation{
int taxamt,fineamt;
String invoiceno;
String dop,year,cashiername;
void cashierinput(){
Scanner s=new Scanner([Link]);
[Link]("This is on the cashiers end!!");
[Link]("Enter the following details in
sequence: Tax amount,fine amount,invoice no,payment
date(month),year, cashier name");
try{
taxamt=[Link]([Link]());
if(taxamt<0){
throw new NegativeAmoutException("The tax amount
should be positve value!");
}
fineamt=[Link]([Link]());
if(fineamt<0){
throw new NegativeAmoutException("The fine amount
should be positive value!");
}
invoiceno=[Link]();
dop=[Link]();
year=[Link]();
cashiername=[Link]();
[Link]("Reading values on the cashier end
done!!");
}catch(NegativeAmoutException e){
[Link](e);
}
};
void bill_print(){
[Link]("The invoice no is:"+invoiceno);
[Link]("The customer's tax is:"+taxamt);
[Link]("The fine amount is:"+fineamt);
[Link]("Cashier name:"+cashiername);
[Link]("Day:"+dop);
};
class Account extends Bill{
int noft;
int totalfine,totaltaxcollected,noofcheq;
void input3(){
[Link]("Enter the data in the specific
order:No of transactions, no of cheques");
Scanner scn=new Scanner([Link]);
try{
noft=[Link]();
if(noft<0){
throw new CountVariable("The no. of transactions
cannot be less than 0");
}
noofcheq=[Link]();
if(noofcheq<0){
throw new CountVariable("The no of cheques
withdrawn has to be greater than or equal to 0");
}
}catch(CountVariable e){
[Link](e);
}
};
void accounts_proccessing(){
totalfine=[Link](dop)*fineamt;
totaltaxcollected=taxamt+totalfine;
[Link]("Account processing is done!!");
};
void print_report(){
[Link]("No of transactions:"+noft);
[Link]("No of cheques
withdrawn:"+noofcheq);
[Link]("Total fine due:"+totalfine);
[Link]("Total amount to be
paid:"+totaltaxcollected);
};
}
class Solution{
public static void main(String[] args) throws Exception{
Account a=new Account();
boolean t=true;
int x;
Scanner f=new Scanner([Link]);
while(t){
[Link]("Choose the type of user");
[Link]("[Link]");
[Link]("[Link]");
[Link]("[Link]");
[Link]("[Link]");
x=[Link]();
switch(x){
case 1:
{
[Link]();
a.print1();
break;
}
case 2:
{
[Link]();
a.bill_print();
break;
}
case 3:
{
a.input3();
a.accounts_proccessing();
a.print_report();
break;
}
case 4:
{
t=false;
}
}
}
[Link]("By-Achintya S Rao(16BCI0158)");
}
}
Output with general case:
Output with Exceptional handling:
Invalid Mobile number exception:
Negative Amount exception:
Count Variable or positive no of transactions and
cheque exception:
x-x-x-x-x-x