0% found this document useful (0 votes)
12 views

Import Java

The document contains code for three Java classes - Bill, tax, and Details. The Bill class calculates electricity bills based on units consumed. The tax class calculates income tax based on taxable income. The Details class handles bank account transactions like deposit, withdrawal, and checking balances. All classes take user input, perform calculations, and display outputs.

Uploaded by

Chetan Lunthi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Import Java

The document contains code for three Java classes - Bill, tax, and Details. The Bill class calculates electricity bills based on units consumed. The tax class calculates income tax based on taxable income. The Details class handles bank account transactions like deposit, withdrawal, and checking balances. All classes take user input, perform calculations, and display outputs.

Uploaded by

Chetan Lunthi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

import java.util.

Scanner;

class Bill
{
 String name;
 int units;
 Double amount;

 Bill(String name,int units)


 {
    this.name=name;
    this.units=units;
 }

 void calculate()
 {
    if(units<=100)
    amount=(0.60*units)+50;
    else if(units<=300)
    amount=60+50+(0.80*(units-100));
    else
    amount=60+160+50+(0.90*(units-300));

    if(amount>300)
    {
        Double m = amount*0.15;
        amount=amount+m;
    }
 }
 void display()
 {
    System.out.println("Name:"+name);
    System.out.println("Units:"+units);
    System.out.println("Amount:"+amount);
 }

 public static void main(String args[])


 {
   Scanner input = new Scanner(System.in);
   System.out.println("Enter The name:");
   String n = input.nextLine();
   System.out.println("Enter Units Consumed:");
   int u=input.nextInt();

   Bill mybill=new Bill(n,u);


   mybill.calculate();
   mybill.display();
   
 }
}
import java.util.Scanner;
class tax
{
    int Pan;
    String name;
    Double taxIncome;
    Double tax;

    tax(int Pan,String name,Double taxIncome)


    {
        this.Pan=Pan;
        this.name=name;
        this.taxIncome=taxIncome;      
    }
    void taxcal()
    {
        if(taxIncome<=250000)
        tax=null;
        else if(taxIncome>=250000 && taxIncome<=300000)
        {
            Double m = taxIncome-250000;
            tax=0.10*m;
        }
        else if(taxIncome>=300000 && taxIncome<=400000)
        {
            Double m = taxIncome-300000;
            tax=(0.20*m)+5000;
        }
        else
        {
            Double m = taxIncome-400000;
            tax=(0.30*m)+25000;
        }
    }
    void displayInfo()
    {
        System.out.println("Pan:"+Pan);
        System.out.println("Name:"+name);
        System.out.println("Tax Income:"+taxIncome);
        System.out.println("Tax:"+tax);
    }

    public static void main(String args[])


    {
        Scanner input = new Scanner(System.in);
        System.out.println("Enter the Pan number:");
        int p=input.nextInt();
        System.out.println("Enter the name:");
        String n=input.next();
        System.out.println("Enter the tax income");
        Double ti=input.nextDouble();

        tax taxableincome=new tax(p,n,ti);


        taxableincome.taxcal();
        taxableincome.displayInfo();

    }
}
import java.util.Scanner;
class Details
{
    String name;
    int acc_no;
    Double balance;
    Double deposit;
    Double withdrawl;

    void set_name(String name)


    {
        this.name = name;
    }
    void set_acc(int acc_no)
    {
        this.acc_no = acc_no;
    }
    void set_balance(Double balance)
    {
        this.balance = balance;
    }

    void deposit(Double deposit)


    {
        this.deposit = deposit;
        balance = balance + deposit;
        System.out.println("Balance after Deposit is:"+balance);
    }
    void withdrawl(Double withdrawl)
    {
        this.withdrawl = withdrawl;
        if(withdrawl>balance)
        {
            System.out.println("Insufficient Balance !!");
        }
        else
        balance = balance - withdrawl;

        System.out.println("Balance after Withdrawl is:"+balance);


    }
    void checkbalance()
    {
        System.out.println("Balance of Account is:"+balance);
    }
    void show()
    {
        System.out.println("Name:"+name);
        System.out.println("Account Number:"+acc_no);
        System.out.println("Balance:"+balance);
    }

    public static void main(String args[])


    {
        Details de = new Details();
        Scanner input = new Scanner(System.in);
        System.out.println("Enter the name of the Customer:");
        String name = input.nextLine();
        de.set_name(name);
        System.out.println("Enter the account number of the Customer:");
        int acc_no = input.nextInt();
        de.set_acc(acc_no);
        System.out.println("Enter the account balance of the customer:");
        Double balance = input.nextDouble();
        de.set_balance(balance);
        System.out.println("Enter the amount to be Deposited:");
        Double deposit = input.nextDouble();
        de.deposit(deposit);
        System.out.println("Enter the amount to be Withdrawn:");
        Double withdrawl = input.nextDouble();
        de.withdrawl(withdrawl);
        de.checkbalance();
        de.show();
    }
}
 

You might also like