java

 avatar
chamanEiqbal
java
a year ago
3.9 kB
2
Indexable
Never
package CHECK;

import java.util.ArrayList;

public class Bill{
public static void main(String []args){
        
    ArrayList<Parts> parts = new ArrayList<>();
    ArrayList<Labour> labour = new ArrayList<>();
   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);
        
        parts.add(obj1);
        parts.add(obj2);
        parts.add(obj3);
        parts.add(obj4);
        
//       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());
      
      labour.add(sc);
      labour.add(sc1);
      
       double totalParts = 0.0;
     for(Parts p: parts) {
         double total = p.total();
        totalParts += total;
     }
     
     double totalLabour = 0.0;
     for(Labour l: labour) {
         double total = l.total();
         totalLabour += total;
     }
     
     System.out.println("total parts: " + totalParts);
     System.out.println("total labour: " + totalLabour);
     System.out.println("Service Tax: " + totalParts * 0.05);
     System.out.println("Grand Total: " + (totalParts + totalLabour + 15));
              
       
         
        
    }
    
}