Activity-8 Name: Achintya S Rao Reg. No: 16BCI0158 Subject: Java Programming Submitted To: Prof. Arun Kumar G
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 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);
};
}
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);
};
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)");
}
}
x-x-x-x-x-x