Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
6.1 kB
4
Indexable
Never
package receipt;
import java.util.Vector;
public class DescriptionDetails {

    public double getQuantity() {
        return quantity;
    }

    public void setQuantity(double quantity) {
        this.quantity = quantity;
    }

    public double getUp() {
        return up;
    }

    public void setUp(double up) {
        this.up = up;
    }

    public String getDm() {
        return dm;
    }

    public void setDm(String dm) {
        this.dm = dm;
    }

   
    private double quantity;
    private double up;
    private String dm;
    
     
         
     }
     
   
 
 class Parts extends DescriptionDetails{
private double discount;
public  double totalParts=0.0;
public Vector<Parts>list=new Vector();
    public double getDiscount() {
        return discount;
    }

    public void setDiscount(double discount) {
        this.discount = discount;
    }
     
     public double total(){
          double t;
          t=getUp()*getQuantity()-(discount);
          return t;
     }
     public void addtotal(Parts in){
         
         list.add(in);
     }
     public double totalparts()
     {
       
         for (int i=0;i<list.size();i++){
         Parts in=list.elementAt(i);
         totalParts+=in.total();
         
         }
        // System.out.printf("Total Parts: %.2f",totalParts);
         //System.out.printf("\n");
         return totalParts;
     }
     public void servicetax(){
         double percent;
         percent= (5.0/100)*totalParts;
         System.out.println("Service tax(5%) is: " + percent);
     }
 
 }
class Labour extends DescriptionDetails{
        public double totallabour=0.0;
 
public Vector<Labour>list=new Vector();
   
     
     public double total(){
          double t;
          t=getUp()*getQuantity();
          return t;
     }
     public void addtotal(Labour in){
         
         list.add(in);
     }
     public double totalLabour()
     {
        
         for (int i=0;i<list.size();i++){
         Labour in=list.elementAt(i);
         totallabour+=in.total();
         
         }
         return totallabour;
//         System.out.printf("Total Labour : %.2f",totalLabour);
//         System.out.printf("\n");
     }
     
 
 }

class main{
   
    public static void main(String []args){
        Parts obj1=new Parts();
         
        obj1.setDm("Filter Oil");
        obj1.setQuantity(1);
        obj1.setUp(24.00);
        obj1.setDiscount(2.40);
        obj1.addtotal(obj1);
        Parts obj2=new Parts();
        obj2.setDm("Genuine Full Synthetic");
        obj2.setDiscount(18.80);
        obj2.setUp(42.50);
        obj2.setQuantity(4.00);
        obj1.addtotal(obj2);
        Parts obj3=new Parts();
        obj3.setDm("Weu Rapid w/screen Cleaner");
        obj3.setDiscount(0);
        obj3.setUp(8.0);
        obj3.setQuantity(1);
        obj1.addtotal(obj3);
        Parts obj4=new Parts();
        
        obj4.setDm("Wedge");
        obj4.setDiscount(0);
        obj4.setUp(3.0);
        obj4.setQuantity(1);
       obj1.addtotal(obj4);
        System.out.print("Parts  Description : "+obj1.getDm());
         System.out.print("  Quantity : "+obj1.getQuantity());
        System.out.print("  Unit Price : "+obj1.getUp());
        System.out.print("  Discount : "+obj1.getDiscount());
       System.out.println("  Parts Total : "+obj1.total());
                         
       System.out.print("Parts  Description : "+obj2.getDm());
     System.out.print("  Discount : "+obj2.getDiscount());
     System.out.print("  Quantity : "+obj2.getQuantity());
     System.out.print("  Unit Price : "+obj2.getUp());
      System.out.println("  Total : "+obj2.total());
  
        
      System.out.print("Parts  Description : "+obj3.getDm());
     System.out.print("  Discount : "+obj3.getDiscount());
     System.out.print("  Quantity : "+obj3.getQuantity());
     System.out.print("  Unit Price : "+obj3.getUp());
      System.out.println("  Total : "+obj3.total());
      System.out.print("Parts  Description : "+obj4.getDm());
     System.out.print("  Discount : "+obj4.getDiscount());
     System.out.print("  Quantity : "+obj4.getQuantity());
     System.out.print("  Unit Price : "+obj4.getUp());
      System.out.println("  Total : "+obj4.total());
      
     Labour sc= new Labour();
     Labour sc1= new Labour();
         sc.setDm("Labour Charge to maintenance service :");
        sc.setQuantity(1.00);
        sc.setUp(45.0);
       sc.addtotal(sc);
        sc1.setDm("Labour Charge to advice services :");
        sc1.setQuantity(1.00);
        sc1.setUp(25.0);
       sc.addtotal(sc1);
       System.out.print("Labour  Description : "+sc.getDm());
         System.out.print("  Quantity : "+sc.getQuantity());
        System.out.print("  Unit Price : "+sc.getUp());
        
       System.out.println("   Total : "+sc.total());
                         
       System.out.print("Labour  Description : "+sc1.getDm());
     
     System.out.print("  Quantity : "+sc1.getQuantity());
     System.out.print("  Unit Price : "+sc1.getUp());
      System.out.println("   Total : "+sc1.total());
      
      
     
      
     
         System.out.printf(" Parts Total: %.2f",obj1.totalparts());
         System.out.printf("\n");
         obj1.servicetax();
             System.out.println(sc.totalLabour());
         
         Bill b=new Bill();
         System.out.println("Additional Repair : 15 ");
         
         b.calculateTotal();
              
       
         
        
    }
}
class Bill{
    private double sum;
     private double repair=15;
    Parts in=new Parts();
    Labour in1=new Labour();
    double t=in.totalparts();
    double t1=in1.totalLabour();
    
    public void calculateTotal(){
        sum=in.totalparts()+in1.totalLabour()+repair;
        System.out.println(" Grand Total : "+sum);
    }
    
}