0% found this document useful (0 votes)
46 views9 pages

Activity-8 Name: Achintya S Rao Reg. No: 16BCI0158 Subject: Java Programming Submitted To: Prof. Arun Kumar G

The document describes a Java program written by Achintya S Rao that models taxation processing. It defines classes like Taxation, Bill, and Account to represent different entities in the taxation workflow. The classes have methods to input data, process accounts, and print outputs. The program uses exception handling to validate input data like mobile numbers, amounts, and counts. It provides a menu-driven interface for users to select customer, cashier or processing roles and see corresponding outputs.

Uploaded by

AchintyaSRao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views9 pages

Activity-8 Name: Achintya S Rao Reg. No: 16BCI0158 Subject: Java Programming Submitted To: Prof. Arun Kumar G

The document describes a Java program written by Achintya S Rao that models taxation processing. It defines classes like Taxation, Bill, and Account to represent different entities in the taxation workflow. The classes have methods to input data, process accounts, and print outputs. The program uses exception handling to validate input data like mobile numbers, amounts, and counts. It provides a menu-driven interface for users to select customer, cashier or processing roles and see corresponding outputs.

Uploaded by

AchintyaSRao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

ACTIVITY-8

Name: Achintya S Rao


Reg. No: 16BCI0158
Subject: Java Programming
Submitted to: Prof. Arun Kumar G

Code:
package solution;

import java.io.*;
import java.util.*;

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(){
System.out.println("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(System.in);
houseno=scn.nextLine();
strname=scn.nextLine();
address=scn.nextLine();
areacode=scn.nextLine();
taxno=scn.nextLine();
ownename=scn.nextLine();
try{
mob=scn.nextLine();
if(mob.length()!=10)
{
throw new InvalidMobile("The mobile number is
invalid.Enter a valid number!");
}
System.out.println("Reading the data is complete!");
}catch(InvalidMobile e){
System.out.println(e);
}

void print1(){
System.out.println("Printing the Owner
details....Please wait!!");
System.out.println("Taxation no:"+taxno);
System.out.println("Owner name:"+ownename);
System.out.println("Mobile number:"+mob);
System.out.println("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(System.in);
System.out.println("This is on the cashiers end!!");
System.out.println("Enter the following details in
sequence: Tax amount,fine amount,invoice no,payment
date(month),year, cashier name");
try{
taxamt=Integer.parseInt(s.nextLine());
if(taxamt<0){
throw new NegativeAmoutException("The tax amount
should be positve value!");
}
fineamt=Integer.parseInt(s.nextLine());
if(fineamt<0){
throw new NegativeAmoutException("The fine amount
should be positive value!");
}
invoiceno=s.nextLine();
dop=s.nextLine();
year=s.nextLine();
cashiername=s.nextLine();
System.out.println("Reading values on the cashier end
done!!");
}catch(NegativeAmoutException e){
System.out.println(e);
}
};
void bill_print(){
System.out.println("The invoice no is:"+invoiceno);
System.out.println("The customer's tax is:"+taxamt);
System.out.println("The fine amount is:"+fineamt);
System.out.println("Cashier name:"+cashiername);
System.out.println("Day:"+dop);
};

class Account extends Bill{


int noft;
int totalfine,totaltaxcollected,noofcheq;

void input3(){
System.out.println("Enter the data in the specific
order:No of transactions, no of cheques");
Scanner scn=new Scanner(System.in);
try{
noft=scn.nextInt();
if(noft<0){
throw new CountVariable("The no. of transactions
cannot be less than 0");
}
noofcheq=scn.nextInt();
if(noofcheq<0){
throw new CountVariable("The no of cheques
withdrawn has to be greater than or equal to 0");
}
}catch(CountVariable e){
System.out.println(e);
}
};

void accounts_proccessing(){
totalfine=Integer.parseInt(dop)*fineamt;
totaltaxcollected=taxamt+totalfine;
System.out.println("Account processing is done!!");
};

void print_report(){
System.out.println("No of transactions:"+noft);
System.out.println("No of cheques
withdrawn:"+noofcheq);
System.out.println("Total fine due:"+totalfine);
System.out.println("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(System.in);
while(t){
System.out.println("Choose the type of user");
System.out.println("1.Customer");
System.out.println("2.Cashier");
System.out.println("3.Processing");
System.out.println("4.Exit");
x=f.nextInt();
switch(x){
case 1:
{
a.customerinput();
a.print1();
break;
}

case 2:
{
a.cashierinput();
a.bill_print();
break;
}

case 3:
{
a.input3();
a.accounts_proccessing();
a.print_report();
break;
}

case 4:
{
t=false;
}
}

}
System.out.println("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

You might also like